Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Marshal = func(v interface{}) (io.Reader, error) { b, err := json.MarshalIndent(v, "", "\t") if err != nil { return nil, err } return bytes.NewReader(b), nil }
Marshal is a function that marshals the object into an io.Reader. By default, it uses the JSON marshaller.
View Source
var Unmarshal = func(r io.Reader, v interface{}) error { return json.NewDecoder(r).Decode(v) }
Unmarshal is a function that unmarshals the data from the reader into the specified value. By default, it uses the JSON unmarshaller.
Functions ¶
func Load ¶
Load loads the file at path into v. Use os.IsNotExist() to see if the returned error is due to the file being missing.
Example ¶
defer os.Remove(storingFile)
ioutil.WriteFile(storingFile, []byte(value), 0666)
var fileLoaded interface{}
err := Load(storingFile, &fileLoaded)
if err != nil {
log.Println(err.Error())
}
fmt.Println(fileLoaded)
Output: map[foo:bar]
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.