Created
December 20, 2019 19:03
-
-
Save kodawah/27b70a46b4614d44452fbb4e8adaf7e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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