Generate atomic Value wrappers automatically

Rather than hand-writing wrappers around atomic.Value, generate them
automatically from the same template. The generator is at
internal/gen-valuewrapper. The generator correctly handles generating
wrapper structs for nillable types.
This commit is contained in:
Abhinav Gupta
2020-05-11 16:05:35 -07:00
parent d9a13c26a5
commit 08f23f163e
7 changed files with 258 additions and 54 deletions

3
gen.go
View File

@@ -24,3 +24,6 @@ package atomic
//go:generate bin/gen-atomicint -name=Int64 -wrapped=int64 -file=int64.go
//go:generate bin/gen-atomicint -name=Uint32 -wrapped=uint32 -unsigned -file=uint32.go
//go:generate bin/gen-atomicint -name=Uint64 -wrapped=uint64 -unsigned -file=uint64.go
//go:generate bin/gen-valuewrapper -name=String -type=string -zero="" -file=string.go
//go:generate bin/gen-valuewrapper -name=Error -type=error -zero=nil -file=error.go