diff options
Diffstat (limited to '')
-rw-r--r-- | cmd/rest-server/main.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/cmd/rest-server/main.go b/cmd/rest-server/main.go index 0bdd1eb..aa921c9 100644 --- a/cmd/rest-server/main.go +++ b/cmd/rest-server/main.go @@ -22,7 +22,7 @@ import ( type restServerApp struct { CmdRoot *cobra.Command Server restserver.Server - CpuProfile string + CPUProfile string listenerAddressMu sync.Mutex listenerAddress net.Addr // set after startup @@ -36,7 +36,7 @@ func newRestServerApp() *restServerApp { Short: "Run a REST server for use with restic", SilenceErrors: true, SilenceUsage: true, - Args: func(cmd *cobra.Command, args []string) error { + Args: func(_ *cobra.Command, args []string) error { if len(args) != 0 { return fmt.Errorf("rest-server expects no arguments - unknown argument: %s", args[0]) } @@ -52,7 +52,7 @@ func newRestServerApp() *restServerApp { rv.CmdRoot.RunE = rv.runRoot flags := rv.CmdRoot.Flags() - flags.StringVar(&rv.CpuProfile, "cpu-profile", rv.CpuProfile, "write CPU profile to file") + flags.StringVar(&rv.CPUProfile, "cpu-profile", rv.CPUProfile, "write CPU profile to file") flags.BoolVar(&rv.Server.Debug, "debug", rv.Server.Debug, "output debug messages") flags.StringVar(&rv.Server.Listen, "listen", rv.Server.Listen, "listen address") flags.StringVar(&rv.Server.Log, "log", rv.Server.Log, "write HTTP requests in the combined log format to the specified `filename` (use \"-\" for logging to stdout)") @@ -103,17 +103,19 @@ func (app *restServerApp) ListenerAddress() net.Addr { return app.listenerAddress } -func (app *restServerApp) runRoot(cmd *cobra.Command, args []string) error { +func (app *restServerApp) runRoot(_ *cobra.Command, _ []string) error { log.SetFlags(0) log.Printf("Data directory: %s", app.Server.Path) - if app.CpuProfile != "" { - f, err := os.Create(app.CpuProfile) + if app.CPUProfile != "" { + f, err := os.Create(app.CPUProfile) if err != nil { return err } - defer f.Close() + defer func() { + _ = f.Close() + }() if err := pprof.StartCPUProfile(f); err != nil { return err |