An auto-generated thread-safe map package written in golang.
go get github.com/ggaaooppeenngg/safemap
Run safemap -k Key_type -v Val_type
to generate a file named Key_type2Val_type.go
in currenty package directory. It will search currenty directory for the definitions of Key_type and Val_type, and define a struct Key_type2Val_typeSafeMap
in the file. You can also use -n
to specify a namespace instead of default Key_type2Value_type
in order to avoid conflicts.
You can also use go generate to automatically generate the code, put a comment in your code like below and run go generate
, a generated file will be found.
//go:generate safemap -k TypeKey -v TypeValue
type TypeKey string
type TypeValue string
or
//go:generate safemap -k string -v TypeValue -n prefix
type TypeValue string