directory
Version:
v0.0.0-...-cf38f87
Opens a new window with list of versions in this module.
Published: Aug 31, 2017
License: Apache-2.0
Opens a new window with license information.
README
¶
Seeds for GenX.
Usage
➤ genx -seed set -t T=string -n main -o ./string_set.go
➤ genx -seed set -t T=uint64 -n main -o ./string_uint64.go
# or
➤ genx -seed atomicMap -t KT=string,VT=uint64 -n main -o ./amap_string_uint64.go
Available Seeds
- A very simple
set
with Set/Unset/Has/Merge/Keys()
support.
- Generate with:
genx -seeds set -t T=YourType -n package-name -o ./set_YourType.go
- Usage:
s := NewYourTypeSet()
- Typed
sync/atomic.Value
with Swap
/CompareAndSwap
support (using a sync.RWMutex
).
- Generate with:
genx -seeds atomicValue -t T=YourType -n package-name -o ./atomic_YourType.go
- Usage:
v := NewAtomicYourType(some initial value) or v := &AtomicYourType{}; old := v.Swap(new value)
- The code generated from this seed is under The Go BSD-style license.
- A modified version of sync.Map to support code gen.
- Generate with:
genx -seeds atomicMap -t KT=YourKeyType,VT=YourValueType -n package-name -o ./somename.go
- Generate with (change name):
genx -seeds atomicMap -t KT=YourKeyType,VT=YourValueType,MapKTVT=somethingPrivate -n package-name -o ./somename.go
- Usage:
var m somethingPrivate; v, loaded := m.LoadOrStore(some key, some default value)
- The code generated from this seed is under The Go BSD-style license.
- Shows how to target native types vs other types with tags.
- For builtin types, it uses builtin-types.go.
- For other types, it expects a
func(i, j int) bool
func, and uses other-types.go.
- A modified version of sort.Slice/sort.SliceStable to support code gen.
- Generate with:
genx -seeds sort -t T=YourType -n package-name -o ./sort_YourType.go
- Usage with a builtin comparable type (
genx -seeds sort -t T=string ...
): SortStrings(stringSlice, true or false for reverse sort)
.
- Usage with other types (
genx -seeds sort -t T=*YourType ...
):
SortYourType(yourSlice, func(i, j) bool { return yourSlice[i].X < yourSlice[j].X })
// for reverse sort
SortYourType(yourSlice, func(j, i) bool { return yourSlice[i].X < yourSlice[j].X })
Todo
- Documention for each seed.
Directories
¶
atomicMap is a seed based on sync.Map in the stdlib.
|
atomicMap is a seed based on sync.Map in the stdlib. |
|
|
|
|
|
|
utils
sort is copied from stdlib, most functions made public to support generic sorters.
|
sort is copied from stdlib, most functions made public to support generic sorters. |
Click to show internal directories.
Click to hide internal directories.