Skip to content

Commit

Permalink
Merge pull request #103 from naveensrinivasan/fix/golangrun-ci-issue
Browse files Browse the repository at this point in the history
fix - golangci-lint issues
  • Loading branch information
inferno-chromium committed Dec 22, 2020
2 parents 9b1e28e + 06f2616 commit 7937da4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 8 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()
}

Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package cmd
import (
"fmt"
"html/template"
"log"
"net/http"
"os"
"strings"
Expand All @@ -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)
Expand Down Expand Up @@ -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)
}
},
}

Expand Down

0 comments on commit 7937da4

Please sign in to comment.