下面实例使用到的结构体
type Website struct {
Name string
}
var site = Website{Name: "duoke360"}
占位符
package main
import "fmt"
type Website struct {
Name string
}
func main() {
var site = Website{Name: "duoke360"}
//默认值 v:var
fmt.Printf("site: %v\n", site) //site: {duoke360}
//包和类的 结构
fmt.Printf("site: %#v\n", site) //site: main.Website{Name:"duoke360"}
//类型 T:type
fmt.Printf("site: %T\n", site) //site: main.Website
a := 100
fmt.Printf("a: %T\n", a) //a: int
}
布尔占位符
package main
import "fmt"
func main() {
/*布尔占位符*/
//%t 单词true或false
b := true
fmt.Printf("b: %t\n", b) //b: true
}
整数占位符
浮点数和复数的组成部分(实部和虚部)
字符串与字节切片
指针
package main
import "fmt"
func main() {
x := 100
p := &x
fmt.Printf("p: %p\n", p) //p: 0xc000018098
}