mirror of
				https://github.com/restic/restic.git
				synced 2025-10-31 03:02:05 +00:00 
			
		
		
		
	get rid of a few global variables
This commit is contained in:
		| @@ -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" | ||||
|   | ||||
| @@ -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) | ||||
| @@ -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) { | ||||
|   | ||||
| @@ -303,7 +303,7 @@ func generateFiles() { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| var versionPattern = `var version = ".*"` | ||||
| var versionPattern = `const version = ".*"` | ||||
|  | ||||
| const versionCodeFile = "cmd/restic/global.go" | ||||
|  | ||||
| @@ -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 { | ||||
| @@ -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") | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Michael Eischer
					Michael Eischer