To declare and initialize a variable of type float32
or float64
in Go, use the following syntax:
main.go60 chars3 lines
You can also use the shorthand :=
operator if you want Go to infer the type of the variable:
main.go102 chars3 lines
Note that if you don't specify the type, Go will automatically default to float64
.
gistlibby LogSnag