這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。Go has various value types including strings, integers, floats, booleans, etc. Here are a few basic examples.
Strings, which can be added together with +
Integers and floats.
Booleans, with boolean operators as you’d expect.
package mainimport "fmt"func main() { fmt.Println("go" + "lang") fmt.Println("1+1 =", 1+1) fmt.Println("7.0/3.0 =", 7.0/3.0) fmt.Println(true && false) fmt.Println(true || false) fmt.Println(!true)}
$ go run values.go
golang
1+1 = 2
7.0/3.0 = 2.3333333333333335
false
true
false
譯:
Go語言中有很多各種各樣的實值型別包括strings、integers、float、boolean、etc.這是一些基本的例子
package mainimport "fmt"func main() { fmt.Println("go" + "lang") fmt.Println("1+1 =", 1+1) fmt.Println("7.0/3.0 =", 7.0/3.0) fmt.Println(true && false) fmt.Println(true || false) fmt.Println(!true)}$ go run values.gogolang1+1 = 27.0/3.0 = 2.3333333333333335falsetruefalse
原文地址