Skip to content

Commit

Permalink
Disable automaxprocs logging
Browse files Browse the repository at this point in the history
When imported using the blank identifier `_`, the automaxprocs package emits
a log after it changes GOMAXPROCS. According to [1], the authors
   wanted to log by default, as setting a global like GOMAXPROCS is a
   significant change which would be surprising if it was done silently
   because some package imported automaxprocs.
Since no one should be importing `cmd/juno` and because we want our log
messages to be consistent, we disable the log by calling Set() explicitly.
[1] uber-go/automaxprocs#18
  • Loading branch information
joshklop committed Jan 4, 2024
1 parent 95de15a commit 38c161b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/juno/juno.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/mitchellh/mapstructure"
"github.com/spf13/cobra"
"github.com/spf13/viper"
_ "go.uber.org/automaxprocs"
"go.uber.org/automaxprocs/maxprocs"
)

const greeting = `
Expand Down Expand Up @@ -128,6 +128,11 @@ const (
var Version string

func main() {
if _, err := maxprocs.Set(); err != nil {
fmt.Printf("error: cannot set maxprocs: %v", err)
return
}

Check warning on line 134 in cmd/juno/juno.go

View check run for this annotation

Codecov / codecov/patch

cmd/juno/juno.go#L131-L134

Added lines #L131 - L134 were not covered by tests

quit := make(chan os.Signal, 1)
signal.Notify(quit, os.Interrupt, syscall.SIGTERM)

Expand Down

0 comments on commit 38c161b

Please sign in to comment.