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: complains about err.Error() call #4598

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

cmd/vet: complains about err.Error() call #4598

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

Comments

@gopherbot
Copy link

by johan.samyn:

What steps will reproduce the problem?
Run 'go tool vet -v' on a go source or package that contains "err.Error()"
somewhere (and works correctly).

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

What do you see instead?
<sourcename>.go:<line>:<col>: no args in Error call

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.
@alexbrainman
Copy link
Member

Comment 1:

An example:
# cat a.go
package main
import (
        "log"
        "os"
)
func main() {
        f, err := os.Open("nosuchfile.txt")
        if err != nil {
                log.Fatal(err.Error())
        }
        defer f.Close()
}
# go tool vet -v a.go
Checking file a.go
a.go:11:13: no args in Error call
go tool vet: exit status 1
#
But, strangely, works without -v
# go tool vet a.go
#
I do not know anything about vet, but quick look shows that it assumes that any "error"
function (like log.Error) must have parameters. Perhaps I am mistaken.
Alex

Status changed to Accepted.

@minux
Copy link
Member

minux commented Jan 2, 2013

Comment 2:

this will be easy to fix after go/types matures.

Labels changed: added priority-later, removed priority-triage.

@rsc
Copy link
Contributor

rsc commented Jan 2, 2013

Comment 3:

we should fix it now. err.Error() is very common.

@minux
Copy link
Member

minux commented Jan 2, 2013

Comment 4:

i think just a special case about Error() suffices, what's your opinion?

@rsc
Copy link
Contributor

rsc commented Jan 2, 2013

Comment 5:

yes, allow Error() with no arguments.

@minux
Copy link
Member

minux commented Jan 17, 2013

Comment 6:

This issue was closed by revision e487ea8.

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

4 participants