ALL


  Why init() is not recommended in Go

golangci lintCurrently, the unified CI's .golangci.yml includes the gochecknoinits checker:# golangci-lint v1.46.2# https://golangci-lint.run/usage/linterslinters: disable-all: true enable: ... - gochecknoinits # Checks that no init functions are present in Go code. ref: https://github.com/leighmcculloch/gochecknoinits ...If Go code uses the init() function, the following error will occur:# golangci-lint runfoo/foo.go:3:1: don't use `init` function (gochecknoinits)func init() {^That is, it's not recommended to use init().Why not to use init()Searching "golang why not use init" on G...

2,885 0       GOLANG INIT() SYNC.ONCE PANIC