Go · lesson 2 of 30 · First stepsDeclare variables
var can name a type, := lets Go choose it. A whole number becomes a fraction only with float64.
02-variables.go Download 02-variables.go
package main
import "fmt"
func main() {
var name string = "Archive"
size := 8 // := declares and sets; Go picks the type
used := 5.5
mounted := true
fmt.Println("Volume:", name)
fmt.Println("Free:", float64(size)-used, "TB")
fmt.Println("Mounted:", mounted)
}
Terminal
$ ./02-variables
Volume: Archive
Free: 2.5 TB
Mounted: trueExercise
Add the number of disks and print it.
TurboShell does not contain Go. These programs are made in Bucket & Code with its Go runtime; the finished file runs on the NAS without Go.