打印
package main
import "fmt"
func main() {
fmt.Println("结尾换行")
fmt.Printf("带\\n 才会换行 \n test")
}
map
- map 必须初始化才能使用(使用make开辟空间),否则会报panic错误
package main
import (
"fmt"
)
type PersonInfo struct {
ID string
Name string
}
func main() {
//var mp map[string]PersonInfo
//mp = make(map[string]PersonInfo)
mp := make(map[string]PersonInfo)
mp["first-key"] = PersonInfo{"1", "Tank"}
fmt.Printf("person type:%T\n", mp)
fmt.Printf("first-key's value: %s\n", mp["first-key"])
fmt.Printf("value type:%T", mp["first-key"])
}
标签:map,string,fmt,基础,PersonInfo,语法,mp,key
From: https://www.cnblogs.com/li-gao-wang/p/16796720.html