摘要:
常见用法 var ages map[string]int // 只声明不初始化是nil,赋值会panic: assignment to entry in nil map fmt.Println(ages == nil) // "true" fmt.Println(len(ages) == 0) // 阅读全文
摘要:
常用函数 t, err := time.Parse(layout,date) // time.Time, error t := time.Date(1995,time.September,22,13,0,0,0,time.UTC) formatedTime := t.Format("Mon, 01/ 阅读全文
摘要:
import "math/rand" n := rand.Intn(100) // n is a random int, 0 <= n < 100 f := rand.Float64() // f is a random float64, 0.0 <= f < 1.0 x := []string{" 阅读全文
摘要:
Structs 类型定义(type)相当于一种别名 将struct定义为一种类型Car NewCar函数return &Car{},返回指针 // car.go package elon // Car implements a remote controlled car. type Car stru 阅读全文
摘要:
不需要手动break default是找不到case时执行 可以对多个case执行同样的操作 operatingSystem := "windows" switch operatingSystem { case "windows", "linux": // do something if the o 阅读全文