Skip to content

cmd/vet: handle constant string addition in printf formats #4599

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

Closed
gopherbot opened this issue Dec 30, 2012 · 4 comments
Closed

cmd/vet: handle constant string addition in printf formats #4599

gopherbot opened this issue Dec 30, 2012 · 4 comments
Milestone

Comments

@gopherbot
Copy link
Contributor

by johan.samyn:

What steps will reproduce the problem?
Run 'go tool vet -v' on a go source that contains a log.Fatalf() or fmt.Sprintf() (or
alike), for which the pattern string is either completely on the next line, or the
pattern string is split in multiple strings that are concatenated with '+'.

What is the expected output?
No complaint from 'go vet'.

What do you see instead?
<sourcefilename>.go:<line>:<col>: can't check non-literal format in
call to Fatalf

Which compiler are you using (5g, 6g, 8g, gccgo)?
8g I guess, cause on Win7 32bit

Which operating system are you using?
Windows 7 (32bit), but I see the same on Ubuntu 12.04 (32bit)

Which version are you using?  (run 'go version')
Go version 1.0.3

Please provide any additional information below.
I searched the Mercurial history for changes to the src/cmd/vet folder, but did not see
anything that indicated this was already solved for the next release.
@gopherbot
Copy link
Contributor Author

Comment 1 by johan.samyn:

An example:
C:\DEV\go> cat go-issue-4599.go
package main
import (
    "log"
    "os"
)
func main() {
    fn := "testfile.txt"
    f, err := os.Open(fn)
    if err != nil {
        log.Fatalf("Error %s opening"+
            " file", err)
    }
    defer f.Close()
}
C:\DEV\go> go tool vet -v go-issue-4599.go
Checking file go-issue-4599.go
go-issue-4599.go:12:3: can't check non-literal format in call to Fatalf
C:\DEV\go> 
--
Johan

@minux
Copy link
Member

minux commented Jan 2, 2013

Comment 2:

Labels changed: added priority-later, go1.1maybe, removed priority-triage, go1.1.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Jan 2, 2013

Comment 3:

The multiline part is not relevant. It's that vet doesn't handle constant string
addition like in "x" + "y". This should be easy to fix.

Labels changed: added go1.1, removed go1.1maybe.

@rsc
Copy link
Contributor

rsc commented Jan 31, 2013

Comment 4:

This issue was closed by revision 87c3c1b.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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

3 participants