Documentation ¶
Overview ¶
Example ¶
var enc Encoder var err error enc = GNjson{Pretty: true} ary1 := []int{1, 2, 3} jsonRes, err := enc.Encode(ary1) if err != nil { panic(err) } var ary2 []int err = enc.Decode(jsonRes, &ary2) if err != nil { panic(err) } fmt.Println(ary1[0] == ary2[0])
Output: true
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadHeaderCSV ¶
ReadHeaderCSV only reads the first line of a CSV/TSV input. It takes a path to a CSV/TSV-encoded file and a separator character. It returns back a map with name of a field, and its index. It also returns an error, if the header could not be read.
func TimeString ¶ added in v0.4.0
Types ¶
type Encoder ¶
type Encoder interface { //Encode takes a Go object and converts it into bytes Encode(input interface{}) ([]byte, error) // Decode takes an input of bytes and decodes it into Go object. Decode(input []byte, output interface{}) error }
Encoder interface allows to switch between different encoding types.
type Format ¶
type Format int
Format sets available output formats
const ( // FormatNone is for cases when format is not set yet. FormatNone Format = iota // CSV sets output to comma-separated values. CSV // CompactJSON sets output into one-liner JSON. CompactJSON // PrettyJSON sets output into easier to read JSON with new lines and // indentations. PrettyJSON // TSV sets output to tab-separated values. TSV )
type GNgob ¶
type GNgob struct{}
GNgob is for serializing data into gob format.
type GNjson ¶
type GNjson struct {
Pretty bool
}
GNjson allows to decode and encode JSON format.
func (GNjson) Decode ¶
Decode converts JSON into a go object. If decoding breaks, it returns an error.
Click to show internal directories.
Click to hide internal directories.