Skip to content

Instantly share code, notes, and snippets.

@kodawah
Created December 20, 2019 19:03
Show Gist options
  • Save kodawah/27b70a46b4614d44452fbb4e8adaf7e1 to your computer and use it in GitHub Desktop.
Save kodawah/27b70a46b4614d44452fbb4e8adaf7e1 to your computer and use it in GitHub Desktop.
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