-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
problem with Go directives #205
Comments
Here you can find discussions about them in revive and gofumpt mgechev/revive#986 mvdan/gofumpt#7 |
I'm unsure what to do with the antonboom-testifylint/analyzer/testdata/src/vendor/golang.org/x/sys/unix/pagesize_unix.go:6:1
-// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
+// +build aix darwin dragonfly freebsd Linux netbsd openbsd solaris
antonboom-testifylint/analyzer/testdata/src/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.go:5:1
-//go:build linux && gccgo && 386
+//go:build Linux && gccgo && 386
antonboom-testifylint/analyzer/testdata/src/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go:5:1
-//go:build linux && (mips || mipsle)
+//go:build Linux && (mips || mipsle)
antonboom-testifylint/analyzer/testdata/src/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go:6:1
-// +build linux
+// +build Linux
antonboom-testifylint/analyzer/testdata/src/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.go:5:1
-//go:build linux && gccgo && arm
+//go:build Linux && gccgo && arm
antonboom-testifylint/analyzer/testdata/src/vendor/golang.org/x/sys/unix/syscall.go:5:1
-//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
+//go:build aix || darwin || dragonfly || freebsd || Linux || netbsd || openbsd || solaris || zos
antonboom-testifylint/analyzer/testdata/src/vendor/golang.org/x/sys/unix/syscall.go:6:1
-// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
+// +build aix darwin dragonfly freebsd Linux netbsd openbsd solaris zos |
You can disable |
Of course, it's what I did. I also apply fixes then nuke the errors with a It's OK, but I would prefer the issue to be reported and maybe fixed |
I'm wondering if the fix couldn't be as simple as replacing https://github.com/huacnlee/autocorrect/blob/main/autocorrect%2Fgrammar%2Fgo.pest#L8 by |
There are a few golang directives that can be used to alter the way Go behaves
These directives are provided in Go comments
Here are some information about them
https://go.dev/doc/comment#syntax
https://pkg.go.dev/go/build#hdr-Build_Constraints
https://go-review.googlesource.com/c/website/+/442516/1..2/_content/doc/comment.md#494
There is a small problem with the regexp used for detecting Go comments
autocorrect/autocorrect/grammar/go.pest
Line 8 in 9602afb
For example if I launch
autocorrect --lint
on this filehttps://github.com/Antonboom/testifylint/blob/eb1257817037b6c67234f07f310e7c2b4fc24cf6/analyzer/testdata/src/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go#L5-L7
it would report to change
linux
toLinux
The whole repository has many examples of code Go directives
while there is no problem to change that on a markdown file, Go string, or in regular Go comment, it would cause issue here
I think the regexp should be fixed.
You can find existing regexp about how to detect them
https://github.com/mgechev/revive/blob/bbe5eb74146a39769ec40e413790dc3975cf8bfe/rule/utils.go#L169
https://github.com/mvdan/gofumpt/blob/52739c56d0efd3647a627598a55e821324f8571b/format/format.go#L320-L334
The text was updated successfully, but these errors were encountered: