Go Basic Data Types
Choose a type based on the value you need to represent.
How it works
Go has booleans, strings, signed and unsigned integers, floating-point and complex values. int has a platform-dependent size. int64 gives a fixed width when a protocol or stored format requires it. Numeric conversions are explicit and can lose information.
Run this Go example
Install Go separately from the official Go downloads and check go version in a new terminal. The reviewed baseline is Go 1.27.3 on Windows amd64; the authored syntax and standard-library APIs require Go 1.22 or newer. Save the complete source below as basic-types.go in a learning folder, then run go run basic-types.go from that folder. These examples use only the standard library.
Bhylu has no Go browser runner. Apache, MySQL, PHP and the JavaScript or Python playground are not required to run these files. File examples own a temporary directory; HTTP client examples create an ephemeral loopback server and close it. They do not contact an external API.
Download the complete basic-types.go · Download all source files with hash checks
For the optional collection download, save download-examples.mjs in a new learning folder and run node download-examples.mjs. A local preview uses node download-examples.mjs http://127.0.0.1:8000/examples/go/. The downloader refuses an existing bhylu-go-examples folder and installs or executes no Go code.
Example
package main
import (
"fmt"
)
func main() {
var count int = 8
var grams int64 = 1250
var fraction float64 = 0.75
var open bool = true
var desk string = "East"
fmt.Printf("%d %d %.2f %t %s\n", count, grams, fraction, open, desk)
}
Expected result
8 1250 0.75 true East
Each formatting verb matches its argument. Store an exact amount of money as a suitably checked integer number of minor units when that fits the application; a float does not promise exact decimal money.
For language rules and APIs, use the Go language specification and standard-library documentation. The fictional examples are learning fixtures, not a deployed parcel service.