摘要:
package main import ( "fmt" "sync" ) func main() { var mapInt = new(sync.Map) //add elem mapInt.Store(1, 1) mapInt.Store(2, 2) mapInt.Store(3, 3) fmt.Println("before delete ... 阅读全文
摘要:
package main import ( "encoding/json" "log" "reflect" "github.com/sanity-io/litter" ) func main() { type Item struct { Id int `json:"id"` Num int `json:"num"` } var itemMap = make(map[... 阅读全文
摘要:
package main import ( "fmt" "time" ) func main() { // ticker inner use chanel ticker := time.NewTicker(time.Second) for { <-ticker.C fmt.Println("tick!") } } 阅读全文
摘要:
package main import ( "time" "github.com/sanity-io/litter" ) func main() { var sliceChan = make(chan []int) go func(c chan []int) { for { select { case <-c: litter.Dump(<-c) def... 阅读全文
摘要:
package main import ( "github.com/sanity-io/litter" ) func main() { var mapInt = make(map[int]int) // add for i := 1; i < 10; i++ { mapInt[i] = i } litter.Dump(mapInt) // update mapInt[3]... 阅读全文
摘要:
package main import "github.com/sanity-io/litter" // slice增删改查,很实用 func main() { var sliceInt []int // init sliceInt = append(sliceInt, []int{1, 2, 3, 4}...) litter.Dump(sliceInt) // remove ind... 阅读全文