Skip to content

Commit

Permalink
get rid of a few global variables
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelEischer committed Apr 22, 2024
1 parent 940a315 commit 484dbb1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/restic/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import (
"golang.org/x/term"
)

var version = "0.16.4-dev (compiled manually)"
const version = "0.16.4-dev (compiled manually)"

// TimeFormat is the format used for all timestamps printed by restic.
const TimeFormat = "2006-01-02 15:04:05"
Expand Down
3 changes: 1 addition & 2 deletions cmd/restic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ func needsPassword(cmd string) bool {
}
}

var logBuffer = bytes.NewBuffer(nil)

func tweakGoGC() {
// lower GOGC from 100 to 50, unless it was manually overwritten by the user
oldValue := godebug.SetGCPercent(50)
Expand All @@ -108,6 +106,7 @@ func main() {
tweakGoGC()
// install custom global logger into a buffer, if an error occurs
// we can show the logs
logBuffer := bytes.NewBuffer(nil)
log.SetOutput(logBuffer)

err := feature.Flag.Apply(os.Getenv("RESTIC_FEATURES"), func(s string) {
Expand Down
6 changes: 3 additions & 3 deletions helpers/prepare-release/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func generateFiles() {
}
}

var versionPattern = `var version = ".*"`
var versionPattern = `const version = ".*"`

const versionCodeFile = "cmd/restic/global.go"

Expand All @@ -313,7 +313,7 @@ func updateVersion() {
die("unable to write version to file: %v", err)
}

newVersion := fmt.Sprintf("var version = %q", opts.Version)
newVersion := fmt.Sprintf("const version = %q", opts.Version)
replace(versionCodeFile, versionPattern, newVersion)

if len(uncommittedChanges("VERSION")) > 0 || len(uncommittedChanges(versionCodeFile)) > 0 {
Expand All @@ -323,7 +323,7 @@ func updateVersion() {
}

func updateVersionDev() {
newVersion := fmt.Sprintf(`var version = "%s-dev (compiled manually)"`, opts.Version)
newVersion := fmt.Sprintf(`const version = "%s-dev (compiled manually)"`, opts.Version)
replace(versionCodeFile, versionPattern, newVersion)

msg("committing cmd/restic/global.go with dev version")
Expand Down

0 comments on commit 484dbb1

Please sign in to comment.