Skip to content

Repository files navigation

wrap

Golang wrappers for pointers, slices, and maps that provide secure access, useful methods, and support for JSON/XML serialization.

usage

package main
import (
"fmt""github.com/twoojoo/wrap"
)
funcmain() {
// wrapped pointerptr:=wrap.NewPointer(10)
ptr.SetValue(20)
v, exists:=ptr.GetValue()
fmt.Println(v, exists) // 20, trueprt.Clear()
v, exists=ptr.GetValue() // 0, false// wrapped sliceslice:=wrap.NewSlice([]int{1, 2, 3})
slice.Append(4, 5, 6)
v, exists=slice.ValueAt(3) // 4, truev, exists=slice.ValueAt(10) // 0, false// wrapped mapm:=wrap.NewMap(map[string]int{"a": 1, "b": 2})
m.Set("c", 3) m.Keys() // ["a", "b", "c"]m.Values() // [1, 2, 3]
}

About

Golang wrappers for pointers, slices and maps that provide secure access, useful methods and JSON / XML serialization support

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages