san-go: github.com/bloom42/san-go Index | Files

package sane

import "github.com/bloom42/san-go"

Package sane is a SANE (https://opensource.bloom.sh/sane) parser and manipulation library.

Index

Package Files

doc.go load.go marshal.go unmarshal.go version.go

Constants

const (
    // Version is the sane's parser version
    Version = "0.8.2"
)

func Load Uses

func Load(file string, v interface{}) error

Load is a sortcut for Readfile + Unmarshal use it like: err = sane.Load("myfile.sane", &myStruct)

func Marshal Uses

func Marshal(data interface{}) ([]byte, error)

Marshal returns the SANE encoding of sata. Behavior is similar to the Go json encoder, except that there is no concept of a Marshaler interface or MarshalSAN function for sub-structs, and currently only definite types can be marshaled (i.e. no `interface{}`). The following struct annotations are supported:

sane:"Field"      Overrides the field's name to output.
omitempty         When set, empty values and groups are not emitted.

Note that pointers are automatically assigned the "omitempty" option, as SANE explicitly does not handle null values (saying instead the label should be dropped). Tree structural types and corresponding marshal types:

*Tree                            (*)struct, (*)map[string]interface{}
[]*Tree                          (*)[](*)struct, (*)[](*)map[string]interface{}
[]interface{} (as interface{})   (*)[]primitive, (*)[]([]interface{})
interface{}                      (*)primitive

Tree primitive types and corresponding marshal types:

uint64     uint, uint8-uint64, pointers to same
int64      int, int8-uint64, pointers to same
float64    float32, float64, pointers to same
string     string, pointers to same
bool       bool, pointers to same

func Unmarshal Uses

func Unmarshal(data []byte, v interface{}) error

Unmarshal decodes the contents of `p` in SANE format into a pointer `v`.

type Decoder Uses

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

Decoder reads and decodes E values from an input stream.

type Marshaler Uses

type Marshaler interface {
    MarshalSANE() ([]byte, error)
}

Marshaler is the interface implemented by types that can marshal themselves into valid SANE.

type Options Uses

type Options struct {
    Name      string
    Include   bool
    OmitEmpty bool
}

type Unmarshaler Uses

type Unmarshaler interface {
    UnmarshalSANE([]byte) error
}

Unmarshaler is the interface implemented by types that can unmarshal a SANE description of themselves. The input can be assumed to be a valid encoding of a SANE value. UnmarshalSANE must copy the SANE data if it wishes to retain the data after returning.

Package sane imports 9 packages (graph). Updated 2019-03-20. Refresh now. Tools for package owners.