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

cmd/vet: Linting for Sprintf fails for multiline strings with inputs on the second line #27422

Closed
tylercloke opened this issue Aug 31, 2018 · 1 comment

Comments

@tylercloke
Copy link

tylercloke commented Aug 31, 2018

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

go version go1.10 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

++> go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/tyler/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/tyler/oc/"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.10/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.10/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/x6/zcsvbh7j3q16y2p3ct5tb7n40000gn/T/go-build687939256=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

package main

import (
	"fmt"
)

func main() {
	fmt.Sprintf("my first input %s with my second input %s with a really long string i want on two lines "+
		"should pass linting for my third input %s", "cat", "dog", "turtle")
}

https://play.golang.org/p/MoGKsOD0tVk

What did you expect to see?

gotvet should pass

What did you see instead?

The above should pass linting but it fails because the last %s is on a different line with:

server/server.go:216:4: Sprintf format %s arg err.Error is a func value, not called (govet)
			fmt.Sprintf("my first input %s with my second input %s with a really long string i want on two lines "+
			^
make: *** [lint] Error 1
@tylercloke tylercloke changed the title [cmd/vet] Linting for Sprintf fails for multiline strings [cmd/vet] Linting for Sprintf fails for multiline strings with inputs on the second line Aug 31, 2018
@tylercloke
Copy link
Author

Oops missed my () on Error.

@FiloSottile FiloSottile changed the title [cmd/vet] Linting for Sprintf fails for multiline strings with inputs on the second line cmd/vet: Linting for Sprintf fails for multiline strings with inputs on the second line Aug 31, 2018
@golang golang locked and limited conversation to collaborators Aug 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants