go.uber.org/atomic/internal/gen-atomicwrapper
gen-atomicwrapper generates wrapper types around other atomic types.
It supports plugging in functions which convert the value inside the atomic type to the user-facing value. For example,
Given, atomic.Value and the functions,
func packString(string) interface{}
func unpackString(interface{}) string
We can run the following command:
gen-atomicwrapper -name String -wrapped Value \
-type string -pack fromString -unpack tostring
This will generate approximately,
type String struct{ v Value }
func (s *String) Load() string {
return unpackString(v.Load())
}
func (s *String) Store(s string) {
return s.v.Store(packString(s))
}
The packing/unpacking logic allows the stored value to be different from the user-facing value.
Package
Files: 1. Third party imports: 0. Imports from organisation: 0. Tests: 0. Benchmarks: 0.
Vars
Types
stringList
This type doesn't have documentation.
| Field name | Field type | Comment |
|---|---|---|
| type |
|
No comment on field. |
Functions
func (*stringList) Set
Uses: strings.Split, strings.TrimSpace.
func (*stringList) String
Uses: strings.Join.
Private functions
func main
References: log.Fatalf, log.SetFlags, os.Args.
func run
References: bytes.Buffer, errors.New, flag.ContinueOnError, flag.NewFlagSet, fmt.Errorf, format.Source, io.WriteString, io.Writer, os.Create, os.Stdout, sort.Strings, time.Now.