package game import ( "encoding/json" "fmt" "os" ) func NewGameFromFile(fileName string) (*Game, error) { jsonBytes, err := os.ReadFile(fileName) if err != nil { return nil, err } var gm Game if err := json.Unmarshal(jsonBytes, &gm); err != nil { return nil, fmt.Errorf("%s: %v\n", fileName, err) } else { return &gm, nil } } func (gm *Game) SetId(id string) { gm.id = id } func (gm *Game) GetId() string { return gm.id }