This was written for CL 27811,
but it got lost in the sea of new files.
Change-Id: I5c52cb23dda499b21a6bb32ed5c586779ccbc2f1
Reviewed-on: https://go-review.googlesource.com/28960
Reviewed-by: Rob Pike <r@golang.org>
This CL adds a script to run vet on std and cmd.
There are a considerable number of false positives,
mostly from legitimate but unusual assembly in
the runtime and reflect packages.
There are also a few false positives that need fixes.
They are noted as such in the whitelists;
they're not worth holding this CL for.
The unsafe pointer check is disabled.
The false positive rate is just too high to be worth it.
There is no cmd/dist/test integration yet.
The tentative plan is that we'll check the local platform
during all.bash, and that there'll be a fast builder that
checks all platforms (to cover platforms that can't exec).
Fixes#11041
Change-Id: Iee4ed32b05447888368ed86088e3ed3771f84442
Reviewed-on: https://go-review.googlesource.com/27811
Reviewed-by: Rob Pike <r@golang.org>
This change makes sure that tests are run with the correct
version of the go tool. The correct version is the one that
we invoked with "go test", not the one that is first in our path.
Fixes#16577
Change-Id: If22c8f8c3ec9e7c35d094362873819f2fbb8559b
Reviewed-on: https://go-review.googlesource.com/28089
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
bytes.Compare has its go prototype in package bytes,
but its implementation in package runtime.
vet used to complain that the prototype was missing.
Now instead:
runtime/asm_amd64.s:1483: [amd64] cannot check cross-package assembly function: Compare is in package bytes
Updates #11041
Change-Id: Ied44fac10d0916d7a34e552c02d052e16fca0c8c
Reviewed-on: https://go-review.googlesource.com/27153
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
The asmdecl check had hand-rolled code that
calculated the size and offset of parameters
based only on the AST.
It included a list of known named types.
This CL changes asmdecl to use go/types instead.
This allows us to easily handle named types.
It also adds support for structs, arrays,
and complex parameters.
It improves the default names given to unnamed
parameters. Previously, all anonymous arguments were
called "unnamed", and the first anonymous return
argument was called "ret".
Anonymous arguments are now called arg, arg1, arg2,
etc., depending on the index in the argument list.
Return arguments are ret, ret1, ret2.
This CL also fixes a bug in the printing of
composite data type sizes.
Updates #11041
Change-Id: I1085116a26fe6199480b680eff659eb9ab31769b
Reviewed-on: https://go-review.googlesource.com/27150
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
cmd/link/link_test.go contains several multi-line
struct tags. Going through an unquote/quote cycle
converts `a
b
c` to "a\nb\nc\n".
This keeps all vet error messages for the standard
library on a single line.
Updates #11041
Change-Id: Ifba1e87297a5174294d1fbf73463fd3db357464f
Reviewed-on: https://go-review.googlesource.com/27129
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Eliminates the following false positive:
cmd/go/go_test.go:1916: possible formatting directive in Error call
The line in question:
tg.t.Error("some coverage results are 0.0%")
Updates #11041
Change-Id: I3b7611fa3e0245714a19bd5388f21e39944f5296
Reviewed-on: https://go-review.googlesource.com/27128
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Large shifts of constants are frequently
used for fancy 32/64 bit detection.
This removes 14 false positives from the
standard library.
Updates #11041
Change-Id: Ib39346e5c161da04c38a6a3067932ef43bf74f2d
Reviewed-on: https://go-review.googlesource.com/27155
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
fmt treats interfaces as being transparent.
As a result, we cannot say with confidence
that any particular verb is wrong.
This fixes the following vet false positives
in the standard library:
database/sql/sql_test.go:210: arg dep for printf verb %p of wrong type: sql.finalCloser
fmt/fmt_test.go:1663: arg nil for printf verb %s of wrong type: untyped nil
go/ast/commentmap.go:328: arg node for printf verb %p of wrong type: ast.Node
net/http/transport_test.go:120: arg c for printf verb %p of wrong type: net.Conn
net/http/httptest/server.go:198: arg c for printf verb %p of wrong type: net.Conn
net/http/httputil/dump_test.go:258: arg body for printf verb %p of wrong type: io.Reader
reflect/set_test.go:81: arg x for printf verb %p of wrong type: io.Writer
reflect/set_test.go:141: arg bb for printf verb %p of wrong type: io.Reader
Updates #11041
Updates #16314
Change-Id: I76df01abb3c34a97b6960f551bed9c1c91377cfc
Reviewed-on: https://go-review.googlesource.com/27127
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
If we cannot infer the asm arch from the filename
or the build tags, assume that it is the
current build arch. Assembly files with no
restrictions ought to be usable on all arches.
Updates #11041
Change-Id: I0ae807dbbd5fb67ca21d0157fe180237a074113a
Reviewed-on: https://go-review.googlesource.com/27151
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
The unsafe.Pointer check allows adding to
and subtracting from uintptrs in order to do
arithmetic.
Some code needs to round uintptrs.
Allow &^ for that purpose.
Updates #11041
Change-Id: Ib90dd2954bb6c78427058271e13f2ce4c4af38fb
Reviewed-on: https://go-review.googlesource.com/27156
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Don't issue a copylock warning about a result type; the function may
return a composite literal with a zero value, which is OK.
Don't issue a copylock warning about a function call on the RHS, or an
indirection of a function call; the function may return a composite
literal with a zero value, which is OK.
Updates #16227.
Change-Id: I94f0e066bbfbca5d4f8ba96106210083e36694a2
Reviewed-on: https://go-review.googlesource.com/24711
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
We had ~30 one way, and these four new occurrences the other way.
Updates #11626
Change-Id: Ic6403dc4905874916ae292ff739d33482ed8e5bf
Reviewed-on: https://go-review.googlesource.com/24683
Reviewed-by: Rob Pike <r@golang.org>
Prior to this change package "foo" had to be installed in order to check
example names in "foo_test" package.
However by the time "foo_test" package is checked a parsed "foo" package
has been already constructed. Use it to check example names.
Also change TestDivergentPackagesExamples test to pass directory of the
package to the vet tool as it is the most common way to invoke it. This
requires changes to errchk to add support for grabbing source files from
a directory.
Fixes#16189
Change-Id: Ief103d07b024822282b86c24250835cc591793e8
Reviewed-on: https://go-review.googlesource.com/24488
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This fixes the obvious bug and makes go vet look for identifiers in foo
package when checking example names in foo_test package.
Note that for this check to work the foo package have to be
installed (using go install).
This commit however doesn't fix TestDivergentPackagesExamples test that
is not implemented correctly and passes only by chance.
Updates #16189
Change-Id: I5c2f675cd07e5b66cf0432b2b3e422ab45c3dedd
Reviewed-on: https://go-review.googlesource.com/24487
Reviewed-by: Dmitri Shuralyov <shurcool@gmail.com>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
The cfg subpackage builds a control flow graph of ast.Nodes.
The lostcancel module checks this graph to find paths, from a call to
WithCancel to a return statement, on which the cancel variable is
not used. (A trivial case is simply assigning the cancel result to
the blank identifier.)
In a sample of 50,000 source files, the new check found 2068 blank
assignments and 118 return-before-cancel errors. I manually inspected
20 of the latter and didn't find a single false positive among them.
Change-Id: I84cd49445f9f8d04908b04881eb1496a96611205
Reviewed-on: https://go-review.googlesource.com/24150
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
- Simplified the code.
- Removed types for slice aliases from composite literals' whitelist, since they
are properly handled by vet.
Fixes#15408
Updates #9171
Updates #11041
Change-Id: Ia1806c9eb3f327c09d2e28da4ffdb233b5a159b0
Reviewed-on: https://go-review.googlesource.com/22318
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
We can trust that untyped composite literals are part of a slice literal
and not emit a vet warning for those.
Fixes#9171
Change-Id: Ia7c081e543b850f8be1fd1f9e711520061e70bed
Reviewed-on: https://go-review.googlesource.com/22000
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
The way that -all works was unclear from the documentation and made
worse by recent changes to the flag package. Improve matters by making
the help message say "default true" for the tests that do default to true,
and tweak some of the wording.
Before:
Usage of vet:
vet [flags] directory...
vet [flags] files... # Must be a single package
For more information run
go doc cmd/vet
Flags:
-all
enable all non-experimental checks (default unset)
-asmdecl
check assembly against Go declarations (default unset)
...
After:
Usage of vet:
vet [flags] directory...
vet [flags] files... # Must be a single package
By default, -all is set and all non-experimental checks are run.
For more information run
go doc cmd/vet
Flags:
-all
enable all non-experimental checks (default true)
-asmdecl
check assembly against Go declarations (default true)
...
Change-Id: Ie94b27381a9ad2382a10a7542a93bce1d59fa8f5
Reviewed-on: https://go-review.googlesource.com/21495
Reviewed-by: Andrew Gerrand <adg@golang.org>
This excludes internal and testdata packages, as well as func types.
No new whitelist entries were found.
Change-Id: Ie7d42ce0a235394e4bcabf09e155726a35cd2d3d
Reviewed-on: https://go-review.googlesource.com/21822
Reviewed-by: Rob Pike <r@golang.org>
- Automatically determine the first argument to check.
- Skip checking matching non-variadic functions.
- Skip checking matching functions accepting non-interface{}
variadic arguments.
- Removed fragile 'magic' code for special cases such as math.Log
and error interface.
Fixes#15067Fixes#15099
Change-Id: Ib313557f18b12b36daa493f4b02c598b9503b55b
Reviewed-on: https://go-review.googlesource.com/21513
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Previously format argument was detected via scanning func type args.
This didn't work when func type couldn't be determined if the func
is declared in the external package. Fall back to scanning for
the first string call argument in this case.
Fixes#14754
Change-Id: I571cc29684cc641bc87882002ef474cf1481e9e2
Reviewed-on: https://go-review.googlesource.com/21023
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
-test flag is a testing only flag that enables all vet checks. It was needed
because there was no way to run all vet checks in a single command
invocation. However it is possible to do this now by combining -all and -shadow
flags.
Also a recently added -tests flag is similarly named, having both -test and
-tests can be confusing.
Change-Id: Ie5bacbe0bef5c8409eeace46f16141fa4e782c32
Reviewed-on: https://go-review.googlesource.com/20006
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
cmd/vet's printf checker currently uses a hardcoded map of function
names to expected positions of format strings. We can be a bit more
precise than this by looking up the signature of the function, which
helps when libraries implement functions like Errorf or Logf with
extra arguments like log levels or error codes.
Specifically, the format string param is assumed to be the last string
parameter of the called function.
Fixes#12294.
Change-Id: Icf10ebb819bba91fa1c4109301417042901e34c7
Reviewed-on: https://go-review.googlesource.com/20163
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
This commit modifies the style of a error message in case of -shadow.
Previously such a message would look like:
foo.go:42: declaration of err shadows declaration at shadow.go:13:
Changes of the commit include highlighting the variable name and
removing the ": "(space intended) at the end of the line:
foo.go:42: declaration of "err" shadows declaration at shadow.go:13
Fixes#14585.
Change-Id: Ia6a6bf396668dcba9a24f025a08d8826db31f434
Reviewed-on: https://go-review.googlesource.com/20093
Reviewed-by: Rob Pike <r@golang.org>
The tree's pretty inconsistent about single space vs double space
after a period in documentation. Make it consistently a single space,
per earlier decisions. This means contributors won't be confused by
misleading precedence.
This CL doesn't use go/doc to parse. It only addresses // comments.
It was generated with:
$ perl -i -npe 's,^(\s*// .+[a-z]\.) +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.) +([A-Z])')
$ go test go/doc -update
Change-Id: Iccdb99c37c797ef1f804a94b22ba5ee4b500c4f7
Reviewed-on: https://go-review.googlesource.com/20022
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Dave Day <djd@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This is a subset of https://golang.org/cl/20022 with only the copyright
header lines, so the next CL will be smaller and more reviewable.
Go policy has been single space after periods in comments for some time.
The copyright header template at:
https://golang.org/doc/contribute.html#copyright
also uses a single space.
Make them all consistent.
Change-Id: Icc26c6b8495c3820da6b171ca96a74701b4a01b0
Reviewed-on: https://go-review.googlesource.com/20111
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
According to golang.org/pkg/testing the first character after Test has
to be non-lowercase. Functions that don't conform to this are not
considered tests and are not loaded which can cause surprises.
This change adds a check to warn about Test-like functions in a _test
file that are not actually run by go test.
Moved over from https://go-review.googlesource.com/#/c/19466/
Change-Id: I2f89676058b27a0e35f721bdabc9fa8a9d34430d
Reviewed-on: https://go-review.googlesource.com/19724
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Given, say, var f *os.File, a new vet check in CL 14122 diagnoses:
fmt.Printf("%s\n", f.Name)
fmt.Println(f.Name)
but not
fmt.Printf("%v\n", f.Name)
In all three cases the error is that the argument should be f.Name().
Diagnosing Println but not Printf %v seems oddly inconsistent,
so I changed %v to have the check too. In fact, all verbs now have
the check except %p and %T.
Fixes Dave Cheney's confusion when trying to write an example
of the new vet check advertised in the Go 1.6 release notes.
Change-Id: I92fa6a7a1d5d9339a6a59ae4e587a254e633f500
Reviewed-on: https://go-review.googlesource.com/19101
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
This was a mistake made when bringing cmd/vet into the main repo.
Fixes#13416.
Change-Id: I03b512ab944577c56085aea06df8ff5e1acc16d7
Reviewed-on: https://go-review.googlesource.com/17455
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Prior to this change "go tool vet -all -shadow" ran only -shadow check.
Also fix godoc package path in the usage text.
Fixes#13020
Change-Id: I87c60d6b06a02106ae8bff56adb79df032cc4646
Reviewed-on: https://go-review.googlesource.com/16325
Reviewed-by: Russ Cox <rsc@golang.org>
Fix for iOS builder.
Change-Id: I5b6c977b187446c848182a9294d5bed6b5f9f6e4
Reviewed-on: https://go-review.googlesource.com/16633
Run-TryBot: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This change fixes shadow assignment check in cases when RHS is not an identifier
or a type assertion.
Fixes#12188
Change-Id: I0940df8d9c237ab8b8d3272eb6895e676c75c115
Reviewed-on: https://go-review.googlesource.com/16038
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Recent changes caused vet to build the binary for each Test function.
This is wasteful and will become only more so as more tests are added.
Use testing.Main to build only once.
Verified that compilation errors still appear if the binary cannot be
built.
Before:
real 0m11.169s
user 0m18.328s
sys 0m2.152s
After:
real 0m5.132s
user 0m9.404s
sys 0m1.168s
Of course if the compiler were fast we might not notice, but vet is
a big program and growing bigger all the time, as are the tests.
Change-Id: I209a8fdcace94bc5cec946f5dd365d7191f44c02
Reviewed-on: https://go-review.googlesource.com/14822
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This means bringing over the examples flag and sorting doc.go.
Subsequent changes will generalize the examples flag to a general
test naming flag, but let's start with the original code.
No more changes to golang.org/x/tools please. This should not have
happened (and letting it happen was partly my fault).
Change-Id: Ia879ea1d15d82372df14853f919263125dfb7b96
Reviewed-on: https://go-review.googlesource.com/14821
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
It went out of its way to look for implicit assignments
but never checked explicit assignments.
This detects the root bug for #12099.
Change-Id: I6a6e774cc38749ea8be7cfd58ba6421247b67000
Reviewed-on: https://go-review.googlesource.com/13646
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
Printing a function value is nearly useless outside of debugging, but
can occur by mistake when one forgets to call it. Diagnose this.
I did this myself just the other day and it arose in cl/14031.
Easy to fix and seems worthwhile.
Fixes#12295.
Change-Id: Ice125a84559f0394f7fa7272b5d31ae602b07f83
Reviewed-on: https://go-review.googlesource.com/14122
Reviewed-by: Andrew Gerrand <adg@golang.org>
This was missed when we did the rename months ago
because cmd/vet did not live in the main tree.
Now vet's asmdecl checks will apply to ppc64 assembly too.
Change-Id: I687cba89fef702f29dd118de76a7ca1041c414f6
Reviewed-on: https://go-review.googlesource.com/13677
Reviewed-by: Andrew Gerrand <adg@golang.org>
The one in misc/makerelease/makerelease.go is particularly bad and
probably warrants rotating our keys.
I didn't update old weekly notes, and reverted some changes involving
test code for now, since we're late in the Go 1.5 freeze. Otherwise,
the rest are all auto-generated changes, and all manually reviewed.
Change-Id: Ia2753576ab5d64826a167d259f48a2f50508792d
Reviewed-on: https://go-review.googlesource.com/12048
Reviewed-by: Rob Pike <r@golang.org>
And vice versa.
The flags are tightly coupled so make the connection clear.
Change-Id: I505f76be631ffa6e489a441c2f3c717aa09ec802
Reviewed-on: https://go-review.googlesource.com/11324
Reviewed-by: Andrew Gerrand <adg@golang.org>
The main change is:
golang.org/cl/10800 add pos parameter to Eval; remove New, EvalNode
followed by several cleanups/follow-up fixes:
golang.org/cl/10992 remove global vars in test
golang.org/cl/10994 remove unused scope parameter from NewSignature
golang.org/cl/10995 provide full source file extent to file scope
golang.org/cl/10996 comment fix in resolver.go
golang.org/cl/11004 updated cmd/vet
golang.org/cl/11042 be robust in the presence of incorrect/missing position info
Fixes#9980.
Change-Id: Id4aff688f6a399f76bf92b84c7e793b8da8baa48
Reviewed-on: https://go-review.googlesource.com/11122
Reviewed-by: Alan Donovan <adonovan@google.com>
Running -copylocks over a large corpus generates 1507 warnings.
Of those, only 3 are from the new anonymous function check,
but they are all bugs.
Fixes#10927.
Change-Id: I2672f6871036bed711beec5f88bc39aa8b3b6a94
Reviewed-on: https://go-review.googlesource.com/11051
Reviewed-by: Rob Pike <r@golang.org>
Forgot this one in my previous commit.
Change-Id: Ief089e99bdad24b3bcfb075497dc259d06cc727c
Reviewed-on: https://go-review.googlesource.com/10913
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Might get the Android build passing, or at least going further.
Change-Id: I08f97156a687abe5a3d95203922f4ffd84fbb212
Reviewed-on: https://go-review.googlesource.com/10924
Reviewed-by: David Crawshaw <crawshaw@golang.org>
- remove TODO on non-existing fmt.Formatter type
(type exists now)
- guard uses of imported types against nil
Change-Id: I9ae8e5a448e73c84dec1606ea9d9ed5ddeee8dc6
Reviewed-on: https://go-review.googlesource.com/10777
Reviewed-by: Alan Donovan <adonovan@google.com>
Add .exe to exectable name, so it can be executed on windows.
Use proper windows paths when searching vet output.
Replace Skip with Skipf.
Fixes build
Change-Id: Ife40d8f5ab9d7093ca61c50683a358d4d6a3ba34
Reviewed-on: https://go-review.googlesource.com/10742
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Patrick Mézard <patrick@mezard.eu>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
- s|"golang.org/x/tools/go/exact"|"go/constant"|
- s|"golang.org/x/tools/go/types"|"go/types"|
- removed import of gcimporter
- import "go/importer" instead
- trivial adjustments to make use of go/importer
- adjusted import paths for whitelist.go
Change-Id: I43488ff44c329cd869c92dcc31193fb31bebfd29
Reviewed-on: https://go-review.googlesource.com/10695
Reviewed-by: Rob Pike <r@golang.org>
cp -r x/tools/cmd/vet cmd/vet without any changes.
The next change will adjust the source to use std
repo go/types and friends.
This may (temporarily) break the build; the next
commit (immediately following) will fix it. We do
it in two commits so that we can see the manual
changes.
Change-Id: Ic45dab7066f13923e21f8c61200c8c3fd447b171
Reviewed-on: https://go-review.googlesource.com/10694
Reviewed-by: Rob Pike <r@golang.org>
- clean up the notypes version of the test so it's quiet
- change the package in the buildtag test to avoid confusing godoc
R=golang-dev, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/8671049
Analogous to the one for .go files, it's for .s only and is protected
by the verbose flag.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/8030046
This is a totally mechanical change.
Errors are reported for the beginning of the statement, not the end,
so the errchk markers need to be on the opening brace, not the closing
one. It seems this test was never run.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7746050
They should be build-tagged for vet_test not ignore,
and not have a Go package clause.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/8016047
Eliminate false positives when you can tell even without
type information that the literal does not need field tags.
Far too noisy otherwise.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7797043
We can enable/disable type checking with a build tag.
Should simplify cutting the go1.1 distribution free of go/types.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7482045
The only check so far is for self-assignments of the form "expr = expr",
but even that found one instance in the standard library.
R=r, adg, mtj, rsc
CC=golang-dev
https://golang.org/cl/7455048
Fixes#4945.
Most examples in this issue now better, but #10 is incomplete and I'm not
certain how to reproduce it. It actually looks like a go/types problem, since
the type being reported is coming directly from that package.
Please reopen the issue if you disagree.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7448046
Also delete bogus tests for f.pkg (does the file have a package) since all
files have a package attached. The tests for pkg.types and pkg.values
suffice.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7418043
And fix test. Pointer to unsafe.Pointer tests nothing important...
Also identify the incorrect type: go/types.Type is a Stringer.
Also fix a couple of incorrect format verbs found by new printf checker,
now that we can run it on more files.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7385051
Also restores the checking of _test.go files, which disappeared
as a result of the package-at-a-time change.
Fixes#4895.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7399051
Then mark them with a build tag so they're not compiled into the binary.
They are called test_*.go rather than *_test.go because they are not
for go test. Use make test to test the command.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7377052
We need go/types to discriminate the Error method from
the error interface and the Error method of the testing package.
Fixes#4753.
R=golang-dev, bradfitz, gri
CC=golang-dev
https://golang.org/cl/7396054
This is a simple refactoring of main.go that will enable the type checker
to be used during vetting.
The change has an unimportant effect on the arguments: it now assumes
that all files named explicitly on the command line belong to the same
package. When run by the go command, this was true already.
Also restore a missing parenthesis from an error message.
R=golang-dev, gri, bradfitz
CC=golang-dev
https://golang.org/cl/7393052
Also:
- faster code for example extraction
- simplify handling of command documentation:
all "main" packages are treated as commands
- various minor cleanups along the way
For commands written in Go, any doc.go file containing
documentation must now be part of package main (rather
then package documentation), otherwise the documentation
won't show up in godoc (it will still build, though).
For commands written in C, documentation may still be
in doc.go files defining package documentation, but the
recommended way is to explicitly ignore those files with
a +build ignore constraint to define package main.
Fixes#4806.
R=adg, rsc, dave, bradfitz
CC=golang-dev
https://golang.org/cl/7333046