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

x/tools/cmd/gotype: (can't find import: ) [GO15VENDOREXPERIMENT=1] #14215

Closed
runningmaster opened this issue Feb 3, 2016 · 15 comments
Closed
Milestone

Comments

@runningmaster
Copy link

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

$ go version
go version go1.6rc1 linux/amd64

2 What operating system and processor architecture are you using?

$ cat /etc/redhat-release 
Fedora release 23 (Twenty Three)

$ lscpu
Architecture:          x86_64
...

3 What did you do?

Project for test:
$GOPATH/src/main/main.go
$GOPATH/src/vendor/github.com/bradfitz/iter/iter.go

$ cat main.go 
package main

import (
    "fmt"
    "github.com/bradfitz/iter"
)

func main() {
    for i := range iter.N(10) {
        fmt.Println(i)
    }
}

4 What did you expect to see?

Nothing (that's OK)

$ gotype main

5 What did you see instead?

$ go env && go version && gotype main
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/dmitriy/Development/go-proj"
GORACE=""
GOROOT="/home/dmitriy/Development/go1.6rc1"
GOTOOLDIR="/home/dmitriy/Development/go1.6rc1/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
go version go1.6rc1 linux/amd64
main/main.go:5:2: could not import github.com/bradfitz/iter (can't find import: )
main/main.go:9:17: undeclared name: iter
main/main.go:9:17: cannot range over iter.N(10) (invalid operand)

Note: other tools from Go Meta Linter work OK.

@ianlancetaylor ianlancetaylor added this to the Unreleased milestone Feb 4, 2016
@ianlancetaylor
Copy link
Contributor

CC @griesemer @alandonovan

@griesemer
Copy link
Contributor

@runningmaster Is this an issue with x/tools/cmd/gotype only? Or also with std lib gotype? (in go/types).

@runningmaster
Copy link
Author

@griesemer

It's also with std lib gotype. I did $ go build gotype.go in go/types and replaced it gotype from x/tools/cmd/gotype. All errors are here.

$ tree -d /home/dmitriy/Development/go-proj/
/home/dmitriy/Development/go-proj/
├── bin
├── pkg
│   └── linux_amd64
│       ├── internal
│       └── vendor
│           └── github.com
│               └── bradfitz
└── src
    ├── internal
    │   └── version
    ├── main
    └── vendor
        └── github.com
            └── bradfitz
                └── iter
$ pwd && echo && cat main.go
/home/dmitriy/Development/go-proj/src/main

package main

import (
    "fmt"

    "github.com/bradfitz/iter"

    "internal/version"
)

func main() {
    for i := range iter.N(10) {
        fmt.Println(version.AppName(), i)
    }
}
$ pwd && echo && go env && echo && go version && echo && gotype main
/home/dmitriy/Development/go-proj/src

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/dmitriy/Development/go-proj"
GORACE=""
GOROOT="/home/dmitriy/Development/go"
GOTOOLDIR="/home/dmitriy/Development/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

go version devel +6a208ef Tue Feb 9 00:17:25 2016 +0000 linux/amd64

main/main.go:6:2: could not import github.com/bradfitz/iter (can't find import: )
main/main.go:12:17: undeclared name: iter
main/main.go:12:17: cannot range over iter.N(10) (invalid operand)

@griesemer
Copy link
Contributor

@runningmaster Temporary work-around: I believe this should work if you provide the full (absolute) path name for main (/home/dmitriy/Development/go-proj/src/main in this case).

But it's clearly a bug. Fix forthcoming.

@gopherbot
Copy link

CL https://golang.org/cl/19393 mentions this issue.

@gopherbot
Copy link

CL https://golang.org/cl/19394 mentions this issue.

@runningmaster
Copy link
Author

@griesemer

Temporary work-around: I believe this should work if you provide the full (absolute) path name for main (/home/dmitriy/Development/go-proj/src/main in this case).

Workaround works fine for go/gotype and x/tools/cmd/gotype too.

$ go env && go version && gotype $(pwd)/main

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/dmitriy/Development/go-proj"
GORACE=""
GOROOT="/home/dmitriy/Development/go"
GOTOOLDIR="/home/dmitriy/Development/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
go version devel +79d9f48 Tue Feb 9 21:12:32 2016 +0000 linux/amd64

Actually I use command go list ./... | grep -v vendor/ | xargs -L1 gometalinter in my bash file for checking my code, but gotype in this case writes errors. Now all works fine (using workaround). Thank you.

runningmaster added a commit to runningmaster/go-proj that referenced this issue Feb 10, 2016
@griesemer
Copy link
Contributor

@runningmaster This has been fixed (at tip) and should not require the work-around anymore.

gopherbot pushed a commit to golang/tools that referenced this issue Feb 10, 2016
This is a backport of the respective changes in golang.org/cl/19393.

For golang/go#14215.

Change-Id: I8d60dd6daa827a60597f3af925e6732914537319
Reviewed-on: https://go-review.googlesource.com/19394
Reviewed-by: Alan Donovan <adonovan@google.com>
runningmaster added a commit to runningmaster/go-proj that referenced this issue Feb 10, 2016
@parhamdoustdar
Copy link

I have the same issue. I'm on Windows. Here is my file structure (I'm running tree from the project folder, but further down I will give the complete path to gometalinter):

C:\Users\Parham\go\src\hamrah7.com\iwr>tree
Folder PATH listing
Volume serial number is D057-3127
C:.
├───client
├───config
├───context
├───httpserver
│   └───handlers
├───pkg
├───serverctl
├───supervisord.d
└───taskprocessor

And here is the output of running gometalinter --deadline=20s %GOPATH%\src\hamrah7.com\iwr\...:

C:\Users\Parham\go\src\hamrah7.com\iwr>gometalinter --deadline=20s %GOPATH%\src\
hamrah7.com\iwr\...
C:\Users\Parham\go\src\hamrah7.com\iwr\...\iwr.go:8:2:error: could not import ha
mrah7.com/iwr/context (can't find import: hamrah7.com/iwr/context) (gotype)
C:\Users\Parham\go\src\hamrah7.com\iwr\...\iwr.go:9:2:error: could not import ha
mrah7.com/iwr/httpserver (can't find import: hamrah7.com/iwr/httpserver) (gotype
)
C:\Users\Parham\go\src\hamrah7.com\iwr\...\iwr.go:11:2:error: could not import h
amrah7.com/iwr/taskprocessor (can't find import: hamrah7.com/iwr/taskprocessor)
(gotype)
C:\Users\Parham\go\src\hamrah7.com\iwr\...\iwr.go:33:13:error: undeclared name:
context (gotype)
C:\Users\Parham\go\src\hamrah7.com\iwr\...\iwr.go:34:2:error: undeclared name: h
ttpserver (gotype)
C:\Users\Parham\go\src\hamrah7.com\iwr\...\iwr.go:58:24:error: undeclared name:
taskprocessor (gotype)
C:\Users\Parham\go\src\hamrah7.com\iwr\...\iwr.go:58:62:error: undeclared name:
taskprocessor (gotype)

I have just installed these, so this isn't an old installation. Also, here is my environment information:

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\Parham\go\
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GO15VENDOREXPERIMENT=
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
go version go1.5.2 windows/amd64

@griesemer
Copy link
Contributor

@parhamdoustdar This should be fixed for 1.6. Please re-open if you still see a problem. Thanks.

@the42
Copy link

the42 commented Mar 22, 2016

I am using gometalinter embedded in atom go-plus which in turn uses gotype. Updated to latest gotype with go get -u

Output of go env && go version && gotype bevaddress.go
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/john/src/gocode"
GORACE=""
GOROOT="/home/john/opt/go"
GOTOOLDIR="/home/john/opt/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
go version go1.6 linux/amd64
bevaddress.go:10:2: could not import github.com/gorilla/websocket (can't find import: github.com/the42/bevaddress/vendor/github.com/gorilla/websocket)
bevaddress.go:11:4: could not import github.com/lib/pq (can't find import: github.com/the42/bevaddress/vendor/github.com/lib/pq)
bevaddress.go:19:16: undeclared name: websocket

The directories gotype complaints no to be able to find are in place. This seems like the error has not been fixed. (Or do I need to update sthg. more but gotype?)

@griesemer
Copy link
Contributor

@the42 Please double-check this and file a new bug since 1.6 has passed. Also, please add your directory structure as otherwise it's not possible to recreate the issue if it really exists. Keep in mind that the "newest" version of gotype is in the std lib go/types directory - you need to build it yourself (there's a separate issue filed to make gotype "go get"-able again (from x/tools). I have just checked that (std lib gotype) code and I believe it's using the latest version of the go/importer which supports vendoring.

@the42
Copy link

the42 commented Mar 22, 2016

@griesemer Before opening a bug I realy think I am using the GOVENDOR-unaware gotype for x/tools. I build go from source, checking out go1.6 and bootstraping with a go1.4. How do I build the go/types gotype?

'which gotype' yields /home/john/src/gocode/bin/gotype

The project I would like to gotype has the following structure:

john@ebola:~/src/gocode/src/github.com/the42/bevaddress$ tree -d
.
├── Godeps
└── vendor
└── github.com
├── gorilla
│   └── websocket
└── lib
└── pq
└── oid

@griesemer
Copy link
Contributor

@the42 In the go/types directory just type: go build gotype.go . That will give you an executable named gotype in that directory that you can use.

@the42
Copy link

the42 commented Mar 22, 2016

Filed as #14918

@golang golang locked and limited conversation to collaborators Mar 22, 2017
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