levonet / docker-golang

Dockerfile for Golang dev.go2go branch
https://hub.docker.com/r/levonet/golang
MIT License
8 stars 2 forks source link

"could not import [package]" error when building with go modules #5

Closed AchoArnold closed 4 years ago

AchoArnold commented 4 years ago

I have the following .go2 code

package main

import (
    "github.com/NdoleStudio/lfu-cache"
)

func main() {
    _, _ = lfucache.New(3)
}
module test.com

go 1.14

require github.com/NdoleStudio/lfu-cache v1.0.1 // indirect

If I attempt to build it with

 docker run --rm -v "$PWD":/go/src/myapp -w /go/src/myapp levonet/golang:go2go go tool go2go build

I get the error

main.go2:1: cannot find package "github.com/NdoleStudio/lfu-cache" in any of:
        /usr/local/lib/go/src/github.com/NdoleStudio/lfu-cache (from $GOROOT)
        /tmp/go2go173741299/src/github.com/NdoleStudio/lfu-cache (from $GOPATH)
        /usr/local/lib/go/src/cmd/go2go/testdata/go2path/src/github.com/NdoleStudio/lfu-cache
        /go/src/github.com/NdoleStudio/lfu-cache
/usr/local/lib/go/bin/go [build] failed: exit status 1

I even tried downloading the dependency before building with the command

 docker run --rm -v "$PWD":/go/src/myapp -w /go/src/myapp levonet/golang:go2go /bin/bash -c "go get -v && go tool go2go build"

And I still get the same error. I'm not sure if this is an issue with this docker image or if the issue is with go2go itself https://github.com/golang/go/issues/40061

AchoArnold commented 4 years ago

Closing this since it's caused by golang/go#40061