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

could not import fmt #105

Open
foolusion opened this issue Sep 25, 2018 · 5 comments
Open

could not import fmt #105

foolusion opened this issue Sep 25, 2018 · 5 comments

Comments

@foolusion
Copy link

I'm getting an error when I run proteus on a very basic example package.

[aoneill@foolxps blah]$ proteus proto -f $HOME/src/aponeill.com/blah/blahpb -p aponeill.com/blah
error scanning package "aponeill.com/blah": /home/aoneill/src/aponeill.com/blah/blah.go:3:8: could not import fmt (/home/aoneill/go-tip/src/fmt/format.go:8:2: could not import strconv (/home/aoneill/go-tip/src/strconv/atof.go:13:8: could not import math (/home/aoneill/go-tip/src/map

the blah package just includes

package blah // import "aponeill.com/blah"

import "fmt"

//proteus:generate
type Blah struct {
        Name string
}

//proteus:generate
func (b *Blah) Blaher() {
        fmt.Println("blah")
}

any idea what is going on here?

@dennwc
Copy link
Contributor

dennwc commented Sep 25, 2018

Looks like something is wrong with GOPATH/GOROOT. What is an output of go env?

@foolusion
Copy link
Author

[aoneill@foolxps blah]$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/aoneill/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/aoneill"
GOPROXY=""
GORACE=""
GOROOT="/home/aoneill/go-tip"
GOTMPDIR=""
GOTOOLDIR="/home/aoneill/go-tip/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build401827573=/tmp/go-build -gno-record-gcc-switches"

[aoneill@foolxps blah]$ go version
go version go1.11 linux/amd64

[aoneill@foolxps blah]$ proteus --version
proteus version 1.0.0

@dennwc
Copy link
Contributor

dennwc commented Sep 25, 2018

The setup is a bit unusual (GOROOT inside GOPATH). It might force proteus to think that package go-tip/src/fmt is some kind of external library, not an fmt package from stdlib. Can you please test if moving GOPATH to a different location (and the project, of course) solves the problem?

@foolusion
Copy link
Author

I moved my GOPATH ~/workspace and kept GOROOT ~/go-tip. That fixed it. It seems strange to me since I've been using this set up for years. Should proteus only search $GOPATH/{src,pkg}?

@dennwc
Copy link
Contributor

dennwc commented Sep 25, 2018

It looks like a bug in https://github.com/src-d/go-parse-utils, since it has a custom import resolver. Filed an issue there: src-d/go-parse-utils#13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants