starting go by example

This commit is contained in:
2021-12-31 15:36:34 +01:00
parent bafba8a7b6
commit afe165089d
11 changed files with 340 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
package main
import (
"fmt"
"math"
)
// const declares a constant value.
const s string = "constant"
func main() {
fmt.Println(s)
// can appear anywhere a var statement can
const n = 500000000
// expressions perform arithmetic with arbitrary precision
const d = 3e20 / n
fmt.Println(d)
// numeric constants have no type until its given one
fmt.Println(int64(d))
// numbers can be given a type by using it in a context that requires one
fmt.Println(math.Sin(n))
}