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
cmd/go/internal/test: -vet accepts bad input #47309
Comments
Change https://golang.org/cl/334873 mentions this issue: |
@matloob per owners |
FWIW, the go/src/cmd/go/internal/vet/vetflag.go Lines 81 to 98 in 3e48c03
Running
Perhaps we should only allow flags whose |
I don't think we should allow configuration of flags like |
Sweet, I too do not see the benefit in having
|
I have some concerns about the complexity of needing to keep these two components in sync, but if there is a clean way to do that, or somehow share the canonical list of vet checks: I am game. I only mention a block list, since I assume this flag list is frozen, except for new checks, meaning it should be pretty future proof. |
@colin-sitehost: Somewhat tangential/unrelated to the main issue. But it could lead to a separate issue in which In this issue description, the output you saw for
However
So if the test binary did run (indicated by the Can you confirm the actual output you saw/are seeing? Thanks. I haven't been able to reproduce on macOS. |
My working directory contains the files from the play link above.// main.go
package main
import "net/http"
func main() {
r, err := http.Get("example")
defer r.Body.Close()
if err != nil {
panic(err)
}
_ = r
} // main_test.go
package main However, now I cannot reproduce it, so I have moved the old text from the description to not confuse the issue further:
|
I can think of at least two such ways. One is to write a Another is to invoke the |
For my understanding, in |
@zpavlinovic, we currently propagate |
This is then probably the most robust way going forward. |
#35487 suggests having an exported list of analyzers available somewhere. This would be robust (but it does mean initializing all of the vet packages just to get their names). |
Should we then block this issue until #35487 is resolved? |
I don't think we need to block it on #35487. We can already scrape That issue seems to be asking for a way to list the analyses used by default by |
Ok, so the plan forward is to rely on |
Change https://golang.org/cl/341334 mentions this issue: |
The vet flag either accepts a list of vets to run, or a distinguished value, off, to disable vet during test. By default only 100% reliable checks are run, thus there is no way to run all vets. This change adds another distinguished value, all, that runs every vet, by passing no flags. During development it was discovered that parsing of the -vet flag value is problematic, in that it accepts deprecated flags like -all. The root cause is detailed in #47309, but for now passing distinguished values (all, off) and anything else returns an error. Fixes #45963 Change-Id: I39fafb7d717dad51b507d560b3f6e604510a2881 Reviewed-on: https://go-review.googlesource.com/c/go/+/334873 Trust: Than McIntosh <thanm@google.com> Trust: Jay Conrod <jayconrod@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://play.golang.org/p/t6Q8DJU3ON6
What did you expect to see?
What did you see instead?
What would you like done?
This came out of development on #45963 [CL 334873]. It was discovered that
go test -vet=all
, actually works today. This is because unlike what the docs say-vet
simply passes the list of "checks", with-
prefixes, togo vet
as flag arguments.This was is an intended feature and seems quite brittle. As such, we should pin
-vet
to the documented interface, or define what "flags" we accept and update the the documentation. If we are not expanding the definition, we should ignore or error on all the deprecated and non-check name flags:-V
,-source
,-c
,-printfuncs
, and-printf.funcs
(anything with a dot). (This is very much a blocklist, since we want to allow new checks to be added over time.)The text was updated successfully, but these errors were encountered: