values

Values

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main

import "fmt"

func main() {
	// 字符串
	fmt.Printf("%v,%T\n", "Hi", "Hi")
	fmt.Printf("%v,%T\n", "Hi "+"golang", "Hi "+"golang")

	// 数值
	fmt.Printf("%v,%T\n", 1, 1)
	fmt.Printf("%v,%T\n", 1.2, 1.2)
	fmt.Printf("%v,%T\n", 1.2+3.4i, 1.2+3.4i)

	// 布尔
	fmt.Printf("%v,%T\n", true, true)
	fmt.Printf("%v,%T\n", false, false)
	fmt.Printf("%v,%T\n", !true, !true)
	fmt.Printf("%v,%T\n", !false, !false)
	fmt.Printf("%v,%T\n", true && false, true && false)
	fmt.Printf("%v,%T\n", true || false, true || false)

	// 其他
	fmt.Printf("%v,%T\n", [10]int{}, [10]int{})
	fmt.Printf("%v,%T\n", []int{}, []int{})
	fmt.Printf("%v,%T\n", make([]int, 10), make([]int, 10))
	fmt.Printf("%v,%T\n", make(map[string]int, 10), make(map[string]int, 10))
	fmt.Printf("%v,%T\n", make(chan int), make(chan int))
	fmt.Printf("%v,%T\n", make(chan int, 10), make(chan int, 10))
	fmt.Printf("%v,%T\n", struct{ Name string }{"zlongx"}, struct{ Name string }{"zlongx"})
}
// Output:
//Hi,string
//Hi golang,string
//1,int
//1.2,float64
//(1.2+3.4i),complex128
//true,bool
//false,bool
//false,bool
//true,bool
//false,bool
//true,bool
//[0 0 0 0 0 0 0 0 0 0],[10]int
//[],[]int
//[0 0 0 0 0 0 0 0 0 0],[]int
//map[],map[string]int
//0xc000096120,chan int
//0xc0000e2000,chan int
最后修改 October 10, 2024: 更新 (a4b8f85)