Go has many different value types including: strings, integers, floats, booleans, etc. Here are a few basic examples.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | package main import "fmt" func main() { // Chuỗi, có thể được thêm vào bằng cách sử dụng dấu "+". fmt.Println("go" + "lang") //Integers and floats. fmt.Println("1+1 =", 1+1) fmt.Println("7.0/3.0 =", 7.0/3.0) // Kiểu logic đúng/sai: Boolean với các toán tử boolean. fmt.Println(true && false) fmt.Println(true || false) fmt.Println(!true) } |
1 2 3 4 5 6 7 8 | $ go run values.go golang 1+1 = 2 7.0/3.0 = 2.3333333333333335 false true false |
The next example: Variables
Source: https://github.com/nhannguyen09cntt/gobyexample/tree/master/examples/values