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/go: report file:line of incorrect import #2664

Closed
gopherbot opened this issue Jan 7, 2012 · 6 comments
Closed

cmd/go: report file:line of incorrect import #2664

gopherbot opened this issue Jan 7, 2012 · 6 comments
Milestone

Comments

@gopherbot
Copy link

by jacobsa@google.com:

What steps will reproduce the problem?
1. mkdir -p $GOPATH/src/tmp/foo
2. cp foo.go foo_test.go $GOPATH/src/tmp/foo
3. cd $GOPATH/src/tmp/foo
4. go test


What is the expected output?

An error message that mentions that package "blah" can't be found.


What do you see instead?

Simply "package could not be found locally". This isn't sufficient when there
are lots of imports in the test.


Which compiler are you using (5g, 6g, 8g, gccgo)?

6g


Which operating system are you using?

OS X 10.7


Which revision are you using?  (hg identify)

52ae6fbcc97a tip

Attachments:

  1. foo.go (76 bytes)
  2. foo_test.go (95 bytes)
@adg
Copy link
Contributor

adg commented Jan 9, 2012

Comment 1:

This is trivial to fix but probably related to rsc's pending work on "go fetch", so I'll
leave it for him.

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

Owner changed to @rsc.

Status changed to Accepted.

@robpike
Copy link
Contributor

robpike commented Jan 13, 2012

Comment 2:

Owner changed to builder@golang.org.

@cookieo9
Copy link
Contributor

Comment 3:

A similar, but slightly different thing happens with the go build command. It prints the
package name that can't be found, but not the file/line number.
I posted my findings to the golang-nuts list:
http://groups.google.com/group/golang-nuts/browse_frm/thread/4b4cfca66001486c/a857297eb742ec15?#a857297eb742ec15

@rsc
Copy link
Contributor

rsc commented Jan 23, 2012

Comment 4:

nice report
---------- Forwarded message ----------
From: Carlos Castillo <cookieo9@gmail.com>
Date: Fri, Jan 20, 2012 at 11:37
Subject: [go-nuts] Go Tool Incomplete Error Messages
To: golang-nuts <golang-nuts@googlegroups.com>
I am using weekly.2012-01-20 on Mac OS X 10.6.8 (darwin-386) and I've
noticed a problem with the error reporting for the go tool.
When I have an error in the import statements the message provided is
far less useful to determining the problem:
$ cat foo.go
package foo
import (
       "bar" // There is no package bar
       "testing"
)
func TestFoo(t *testing.T) {
}
$ 8g foo.go
foo.go:4: can't find import: "bar"
$ go build
.: import bar
       package could not be found locally
.: import bar
       package could not be found locally
The error message provided by the go tool omits the file name and line
number making it much more difficult to find the problem in a large
package.
The problem is even worse for go test, by renaming the above file to
foo_test.go and having a valid foo.go:
$ mv foo.go foo_test.go
$ echo package foo > foo.go
$ go test
package could not be found locally
The error message is even worse since it doesn't even tell me which
package couldn't be found.

Owner changed to @rsc.

@rsc
Copy link
Contributor

rsc commented Jan 30, 2012

Comment 6:

Labels changed: added go1-must.

@remyoudompheng
Copy link
Contributor

Comment 7:

This issue was closed by revision e818536.

Status changed to Fixed.

@rsc rsc added this to the Go1 milestone Apr 10, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc removed their assignment Jun 22, 2022
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

6 participants