Documentation ¶
Overview ¶
Package generic provides structured data handling library like JSON.
Index ¶
- type Cursor
- func (c *Cursor) Delete()
- func (c *Cursor) Index(keys ...interface{}) (nextCursor *Cursor, err error)
- func (c *Cursor) Interface() interface{}
- func (c *Cursor) IsValid() bool
- func (c *Cursor) Keys() (keys []string)
- func (c *Cursor) Len() int
- func (c *Cursor) Push(values ...interface{})
- func (c *Cursor) Set(value interface{})
- func (c *Cursor) SetIndex(keys ...interface{}) (nextCursor *Cursor, err error)
- func (c *Cursor) Slice(i, j int) (nextCursor *Cursor)
- func (c *Cursor) Slice3(i, j, k int) (nextCursor *Cursor)
- func (c *Cursor) String() string
- type GenericError
- type M
- type S
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cursor ¶
type Cursor struct {
// contains filtered or unexported fields
}
func (*Cursor) Index ¶
Example ¶
package main import ( "encoding/json" "fmt" "github.com/go-library/generic" "log" ) func main() { 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]]]
type GenericError ¶
type GenericError struct {
// contains filtered or unexported fields
}
func Error ¶
func Error(args ...interface{}) GenericError
func Errorf ¶
func Errorf(format string, args ...interface{}) GenericError
func (GenericError) Error ¶
func (e GenericError) Error() string
Click to show internal directories.
Click to hide internal directories.