generic: github.com/go-library/generic Index | Examples | Files

package generic

import "github.com/go-library/generic"

Package generic provides structured data handling library like JSON.

Index

Examples

Package Files

cursor.go error.go generic.go

type Cursor Uses

type Cursor struct {
    // contains filtered or unexported fields
}

func Must Uses

func Must(cur *Cursor, err error) *Cursor

func NewCursor Uses

func NewCursor(root *interface{}) *Cursor

func (*Cursor) Delete Uses

func (c *Cursor) Delete()

func (*Cursor) Index Uses

func (c *Cursor) Index(keys ...interface{}) (nextCursor *Cursor, err error)

Code:

var (
    err error
    v   interface{}
    c   *generic.Cursor
)

stream := `{"results": [{"name": "foo" }]}`

err = json.Unmarshal([]byte(stream), &v)
if err != nil {
    log.Fatal(err)
}

c = generic.NewCursor(&v)
generic.Must(c.Index("results", 0, "name")).Set("bar")

fmt.Println(generic.Must(c.Index("results", 0, "name")))
fmt.Printf("%+v\n", v)

Output:

bar
map[results:[map[name:bar]]]

func (*Cursor) Interface Uses

func (c *Cursor) Interface() interface{}

GETTERS

func (*Cursor) IsValid Uses

func (c *Cursor) IsValid() bool

func (*Cursor) Keys Uses

func (c *Cursor) Keys() (keys []string)

func (*Cursor) Len Uses

func (c *Cursor) Len() int

func (*Cursor) Push Uses

func (c *Cursor) Push(values ...interface{})

func (*Cursor) Set Uses

func (c *Cursor) Set(value interface{})

func (*Cursor) SetIndex Uses

func (c *Cursor) SetIndex(keys ...interface{}) (nextCursor *Cursor, err error)

func (*Cursor) Slice Uses

func (c *Cursor) Slice(i, j int) (nextCursor *Cursor)

func (*Cursor) Slice3 Uses

func (c *Cursor) Slice3(i, j, k int) (nextCursor *Cursor)

func (*Cursor) String Uses

func (c *Cursor) String() string

type GenericError Uses

type GenericError struct {
    // contains filtered or unexported fields
}

func Error Uses

func Error(args ...interface{}) GenericError

func Errorf Uses

func Errorf(format string, args ...interface{}) GenericError

func (GenericError) Error Uses

func (e GenericError) Error() string

type M Uses

type M map[string]interface{}

type S Uses

type S []interface{}

Package generic imports 2 packages (graph). Updated 2016-11-16. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).