Skip to content
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

fmt: skip checking the number of args in format for go build and different from go test #29849

Closed
meilihao opened this issue Jan 21, 2019 · 1 comment

Comments

@meilihao
Copy link

commented Jan 21, 2019

What version of Go are you using (go version)?

go version go1.12beta2 linux/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/chen/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/chen/git/go"
GOPROXY=""
GORACE=""
GOROOT="/opt/go"
GOTMPDIR=""
GOTOOLDIR="/opt/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build582535812=/tmp/go-build -gno-record-gcc-switches"

What did you do?

t.go:

package main

import "fmt"

func main() {
	fmt.Println(GenaratePath())
}

func GenaratePath() string {
	return fmt.Sprintf("/tmp/%s_%s",
		"1")
}

t_test.go

package main

import "testing"

func TestGenaratePath(t *testing.T) {
	tmp := GenaratePath()
	if tmp == "" {
		t.Fatal(tmp)
	}
}

run:

> ~/t/t go build                                                                                                                                                                    
⋊> ~/t/t ls                                                                                                                                                                          
t*  t.go  t_test.go
⋊> ~/t/t go test -v                                                                                                                                                                  
# _/home/chen/tmpfs/t
./t.go:10:9: Sprintf format %s reads arg #2, but call has 1 arg
FAIL	_/home/chen/tmpfs/t [build failed]

What did you expect to see?

check the number of args and tags's type in format for go build

@meilihao meilihao changed the title fmt: skip checking the number of args in format for go build and fmt: skip checking the number of args in format for go build and different from go test Jan 21, 2019

@mvdan

This comment has been minimized.

Copy link
Member

commented Jan 21, 2019

The error is coming from go vet, which now runs automatically with go test. This is why go build is not showing you the error.

I don't think it's planned for go build to also run go vet, and there's good reason - builds shouldn't be slowed down.

@mvdan mvdan closed this Jan 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.