Skip to content

Instantly share code, notes, and snippets.

@kodabb
Created December 20, 2019 19:03
Embed
What would you like to do?
func LoadAllPrintings(allPrintingsPath string) error {
allPrintingsReader, err := os.Open(allPrintingsPath)
if err != nil {
return err
}
defer allPrintingsReader.Close()
dec := json.NewDecoder(allPrintingsReader)
_, err = dec.Token()
if err != nil {
return err
}
for dec.More() {
val, err := dec.Token()
if err != nil {
return err
}
set, ok := val.(string)
if ok {
var edition struct {
Name string `json:"name"`
Cards []CardEntry `json:"cards"`
}
err = dec.Decode(&edition)
if err != nil {
return err
}
AllPrintingsDB[set] = edition.Cards
SetNameToCode[edition.Name] = set
}
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment