Go has various value types including strings, integers, floats, booleans, etc. Here are a few basic examples.
$ go run values.go
golang
1+1 = 2
7.0/3.0 = 2.3333333333333335
false
true
false
原文地址
Strings, which can be added together with +
Integers and floats.Booleans, with boolean operators as you’d expect.
package main import "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 main import "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
原文地址
有疑问加站长微信联系(非本文作者)