Skip to content

Commit

Permalink
fix: do not use global variable
Browse files Browse the repository at this point in the history
  • Loading branch information
juev committed Dec 8, 2023
1 parent 6959ccb commit f2a040f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions gobrew.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ type GoBrew struct {
downloadsDir string
}

var gb GoBrew

// NewGoBrew instance
func NewGoBrew() GoBrew {
homeDir, err := os.UserHomeDir()
Expand All @@ -72,6 +70,7 @@ func NewGoBrew() GoBrew {
}

func NewGoBrewDirectory(homeDir string) GoBrew {
gb := GoBrew{}
gb.homeDir = homeDir

gb.installDir = filepath.Join(gb.homeDir, goBrewDir)
Expand Down Expand Up @@ -281,9 +280,7 @@ func (gb *GoBrew) ListRemoteVersions(print bool) map[string][]string {
tags := gb.getGolangVersions()

var versions []string
for _, tag := range tags {
versions = append(versions, tag)
}
versions = append(versions, tags...)

return gb.getGroupedVersion(versions, print)
}
Expand Down
2 changes: 1 addition & 1 deletion gobrew_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func TestUpgrade(t *testing.T) {
binaryFile := filepath.Join(binaryDir, baseName)

if oldFile, err := os.Create(binaryFile); err == nil {
// on tests we have to close the file to avoid an error on os.Rename
// on tests, we have to close the file to avoid an error on os.Rename
_ = oldFile.Close()
}

Expand Down

0 comments on commit f2a040f

Please sign in to comment.