fix - golangci-lint issues

Fixed the golangci-lint issues.
This commit is contained in:
naveen 2020-12-22 16:20:10 -05:00
parent 6549eccacc
commit 06f2616e7e
2 changed files with 14 additions and 3 deletions

View File

@ -58,6 +58,7 @@ var rootCmd = &cobra.Command{
cfg := zap.NewProductionConfig()
cfg.Level.SetLevel(*logLevel)
logger, _ := cfg.Build()
// nolint
defer logger.Sync() // flushes buffer, if any
sugar := logger.Sugar()
@ -158,7 +159,9 @@ func outputCSV(results []pkg.Result) {
}
fmt.Fprintln(os.Stderr, "CSV COLUMN NAMES")
fmt.Fprintf(os.Stderr, "%s\n", strings.Join(columns, ","))
w.Write(record)
if err := w.Write(record); err != nil {
log.Panic(err)
}
w.Flush()
}
@ -196,7 +199,10 @@ func init() {
rootCmd.PersistentFlags().AddGoFlagSet(goflag.CommandLine)
rootCmd.Flags().Var(&repo, "repo", "repository to check")
rootCmd.Flags().StringVar(&format, "format", formatDefault, "output format. allowed values are [default, csv, json]")
rootCmd.MarkFlagRequired("repo")
if err := rootCmd.MarkFlagRequired("repo"); err != nil {
log.Panic(err)
}
rootCmd.Flags().BoolVar(&showDetails, "show-details", false, "show extra details about each check")
checkNames := []string{}
for _, c := range checks.AllChecks {

View File

@ -17,6 +17,7 @@ package cmd
import (
"fmt"
"html/template"
"log"
"net/http"
"os"
"strings"
@ -39,6 +40,7 @@ var serveCmd = &cobra.Command{
cfg := zap.NewProductionConfig()
cfg.Level.SetLevel(*logLevel)
logger, _ := cfg.Build()
//nolint
defer logger.Sync() // flushes buffer, if any
sugar := logger.Sugar()
t, err := template.New("webpage").Parse(tpl)
@ -76,7 +78,10 @@ var serveCmd = &cobra.Command{
port = "8080"
}
fmt.Printf("Listening on localhost:%s\n", port)
http.ListenAndServe(fmt.Sprintf("0.0.0.0:%s", port), nil)
err = http.ListenAndServe(fmt.Sprintf("0.0.0.0:%s", port), nil)
if err != nil {
log.Fatal("ListenAndServe ", err)
}
},
}