go: cmd/go: dots in import statement causes error in finding packages under $GOPATH

Please answer these questions before submitting your issue. Thanks!

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

go version go1.8.1 linux/amd64

What operating system and processor architecture are you using (go env)?

GOARCH=“amd64”
GOBIN=“”
GOEXE=“”
GOHOSTARCH=“amd64”
GOHOSTOS=“linux”
GOOS=“linux”
GOPATH=“/home/verhees/development/go”
GORACE=“”
GOROOT=“/usr/local/go”
GOTOOLDIR=“/usr/local/go/pkg/tool/linux_amd64”
GCCGO=“gccgo”
CC=“gcc”
GOGCCFLAGS=“-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build251409227=/tmp/go-build -gno-record-gcc-switches”
CXX=“g++”
CGO_ENABLED=“1”
PKG_CONFIG=“pkg-config”
CGO_CFLAGS=“-g -O2”
CGO_CPPFLAGS=“”
CGO_CXXFLAGS=“-g -O2”
CGO_FFLAGS=“-g -O2”
CGO_LDFLAGS=“-g -O2”

What did you do?

I did: go get github.com/antlr/antlr4/runtime/Go/antlr

I run the antlr grammar and had the result go-files in the directory parser which is a subdirectory from the project directory (which is again a subdirectory of the $GOPATH/src

I used the library in import like this:

import ( “github.com/antlr/antlr4/runtime/Go/antlr” “./parser” “os” “fmt” )

What did you expect to see?

I expected to see the program (very small program ) run

What did you see instead?

I got an error: /usr/local/go/pkg/tool/linux_amd64/link: cannot open file /usr/local/go/pkg/linux_amd64/github.com/antlr/antlr4/runtime/Go/antlr.a: open /usr/local/go/pkg/linux_amd64/github.com/antlr/antlr4/runtime/Go/antlr.a: no such file or directory

It was clear that it did not look in the $GOPATH/src diectory for the module.

I found somewhere on the internet something about dots in an import statement, and I changed my import like this: import ( “github.com/antlr/antlr4/runtime/Go/antlr” “antlr_experiments/JSON_experiment/parser” “os” “fmt” )

And now everything runs fine.

Thanks for reading, I hope this is useful for you.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

I wouldn’t bother to answer at all if I were you. What you ask is ridicolous. You should have warned me before I spent time reporting a problem.