Exemplo n.º 1
0
// Read reads and parses the JSON-encoded contents of the named metadata file.
// Returns an error if the named file cannot be read or correctly parsed.
func (m *Metadata) Read(name string) error {
	if err := util.ReadJson(name, &m); err != nil {
		return err
	}
	m.path = name
	return nil
}
Exemplo n.º 2
0
// Read reads and parses the JSON-encoded contents of the named file and stores
// the result in the whitelist.
// Returns an error if the named file cannot be read or correctly parsed.
func (w *Whitelist) Read(name string) error {
	if util.IsDir(name) {
		return fmt.Errorf("%s: is a directory", name)
	}
	if err := util.ReadJson(name, &w); err != nil {
		return err
	}
	return nil
}