Newer
Older
package importer
import (
"encoding/json"
"fmt"
"os"
)
type Listing []User
type User struct {
Uuid string
Fullname string
Email string
Admin bool
}
func ReadListingFile(path string) (Listing, error) {
f, err := os.Open(path)
if err != nil {
return nil, fmt.Errorf("Error while opening %s: %s", path, err.Error())
}
defer f.Close()
configDecoder := json.NewDecoder(f)
var listing Listing
err = configDecoder.Decode(&listing)
if err != nil {
return nil, fmt.Errorf("Error parsing listing file %s: %s", path, err.Error())
}
return listing, nil
}