采用开源的线程安全Map项目,引入包:github.com/orcaman/concurrent-map
package service import ( cmap "github.com/orcaman/concurrent-map" ) //定义map var DictMap cmap.ConcurrentMap func init(){ //初始化化map DictMap= cmap.New() } //写入 go fset(){ DictMap.Set("abc","123") } //读取 go Rget(){ ver:=DictMap.Get("abc") } //移除 go Dremove(){ DictMap.Remove("abc") }