package steam import ( "os" "path/filepath" ) // GetSize returns the size of a game in a pretty format. If size is 0 // it will call SetSizeInfo before returning func (g *Game) GetSize() string { if g.Size == 0 { _ = g.SetSizeInfo() } return formatBytes(g.Size) } // SetSizeInfo reads the size information for the game off of the disk // and stores it in the Size struct element func (g *Game) SetSizeInfo() error { pth := filepath.Join(g.LibraryPath, "common", g.Name) return filepath.Walk(pth, func(path string, info os.FileInfo, err error) error { if err != nil { return err } if info.Mode().IsRegular() { g.Size += info.Size() } return nil }) }