Add aggressive linting
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
2022-01-24 20:25:52 +01:00
parent 763d691b6c
commit e7b0c5fa33
18 changed files with 188 additions and 32 deletions

View File

@@ -22,8 +22,11 @@ func ActionServe(c *cli.Context) error {
configPath = c.String("config")
}
var cfg *gpaste.ServerConfig
var r io.ReadCloser
var (
cfg *gpaste.ServerConfig
r io.ReadCloser
)
r, err := os.Open(configPath)
if err != nil {
cfg = &gpaste.ServerConfig{
@@ -52,8 +55,10 @@ func ActionServe(c *cli.Context) error {
// Setup contexts for clean shutdown
rootCtx, rootCancel := signal.NotifyContext(context.Background(), os.Interrupt)
defer rootCancel()
httpCtx, httpCancel := context.WithCancel(rootCtx)
defer httpCancel()
httpShutdownCtx, httpShutdownCancel := context.WithCancel(context.Background())
defer httpShutdownCancel()
@@ -66,14 +71,18 @@ func ActionServe(c *cli.Context) error {
// Wait for cancel
go func() {
<-httpCtx.Done()
timeoutCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
timeoutCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second) // nolint: gomnd
defer cancel()
srv.Shutdown(timeoutCtx)
_ = srv.Shutdown(timeoutCtx)
}()
serverLogger.Infow("Starting HTTP server.", "addr", cfg.ListenAddr)
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
serverLogger.Errorw("Error during shutdown.", "error", err)
}
serverLogger.Infow("HTTP server shutdown complete.", "addr", cfg.ListenAddr)
httpShutdownCancel()
}()

View File

@@ -29,5 +29,5 @@ func main() {
Action: actions.ActionServe,
}
app.Run(os.Args)
_ = app.Run(os.Args)
}