Skip to content

Commit 6d423a4

Browse files
committed
Disable automaxprocs logging
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
1 parent 95de15a commit 6d423a4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cmd/juno/juno.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"github.com/mitchellh/mapstructure"
1818
"github.com/spf13/cobra"
1919
"github.com/spf13/viper"
20-
_ "go.uber.org/automaxprocs"
20+
"go.uber.org/automaxprocs/maxprocs"
2121
)
2222

2323
const greeting = `
@@ -128,6 +128,11 @@ const (
128128
var Version string
129129

130130
func main() {
131+
if _, err := maxprocs.Set(); err != nil {
132+
fmt.Printf("error: set maxprocs: %v", err)
133+
return
134+
}
135+
131136
quit := make(chan os.Signal, 1)
132137
signal.Notify(quit, os.Interrupt, syscall.SIGTERM)
133138

0 commit comments

Comments
 (0)