Open kolyshkin opened 2 years ago
Same issue with another repo: https://goreportcard.com/report/github.com/moby/moby
@kolyshkin I think this may be the same issue as https://github.com/gojp/goreportcard/issues/364, meaning these errors wouldn't show up if a new version were released (not totally sure though).
Hmm. Now the links in warnings point out to v1.0.2 release, which does not have //go:build
tags, so I'm totally unsure what it complains about.
@kolyshkin I took one file and ran gofmt -s -w
on it as a test:
libcontainer/apparmor/apparmor_unsupported.go
Before gofmt -s
:
// +build !linux
package apparmor
func isEnabled() bool {
return false
}
func applyProfile(name string) error {
if name != "" {
return ErrApparmorNotEnabled
}
return nil
}
After:
//go:build !linux
// +build !linux
package apparmor
func isEnabled() bool {
return false
}
func applyProfile(name string) error {
if name != "" {
return ErrApparmorNotEnabled
}
return nil
}
Ah, so it's vice versa -- it doesn't like the absense of go:build tags.
This is going to be a problem with lots of packages I guess, since those tags are not really required until at least Go 1.19.
OTOH this points out to a potential future problem, so maybe it's not a bug, it's a feature!
I am using just //go:build
tags, have go 1.17
requirement in go.mod
and still get this warning. I have tags in 250+ files so I get a bad report.
I cannot even add old style with gofmt (i.e. add just blank // +build
and gofmt should do the job) because it is "too complex":
//go:build ((aix || dragonfly || freebsd || linux || netbsd || openbsd || solaris || illumos) && !motif) || gtk
// +build error: expression too complex for // +build lines
I would not want to maintain this manually in two different styles where the old one is not readable at all, and I already need some other features from Go 1.17.
We have recently added Go 1.17+ go:build tags to runc (see https://github.com/opencontainers/runc/pull/3185/commits/d8da00355e305f0564a9de6854bf5df1aa4b73d9) and that resulted in goreportcard giving warnings on gofmt -s, like this (from https://goreportcard.com/report/github.com/opencontainers/runc):
Apparently, some older version of gofmt is used, which does not understand go:build tags.