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: get error for symlinks in GOPATH #36653

Open
sguillia opened this issue Jan 20, 2020 · 1 comment
Open

cmd/go: get error for symlinks in GOPATH #36653

sguillia opened this issue Jan 20, 2020 · 1 comment
Milestone

Comments

@sguillia
Copy link

@sguillia sguillia commented Jan 20, 2020

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

$ go version
go version go1.13.6 linux/amd64

Does this issue reproduce with the latest release?

If 1.13.6 is the latest, yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN="/home/sg/go/bin"
GOCACHE="/home/sg/.cache/go-build"
GOENV="/home/sg/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/user/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/sg/Applications/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/sg/Applications/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
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-build163278137=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Step 1
Create the /home/user directory so you can reproduce in a clean environment

Step 2
export GOPATH=/home/user/go

Step 3
Set-up the following hierarchy

tree view

$ tree /home/user
/home/user
├── go
│   └── src
│       └── github.com
│           └── sguillia
│               └── foo -> /home/user/projects/foo
└── projects
    └── foo
        ├── bar
        │   └── bar.go
        └── main.go

find view

$ find /home/user
/home/user
/home/user/projects
/home/user/projects/foo
/home/user/projects/foo/bar
/home/user/projects/foo/bar/bar.go
/home/user/projects/foo/main.go
/home/user/go
/home/user/go/src
/home/user/go/src/github.com
/home/user/go/src/github.com/sguillia
/home/user/go/src/github.com/sguillia/foo

main.go

package main

import "github.com/sguillia/foo/bar"

func main() {
	bar.Bar()
}

bar.go

package bar

import "fmt"

func Bar() {
	fmt.Println("Hello world")
}

/home/user/go/src/github.com/sguillia/foo is a symlink to /home/user/projects/foo

Step 4

cd /home/user/projects/foo
go get -d -u .

What did you expect to see?

I expected go to update foo, as if there was no symlink.

What did you see instead?

package _/home/user/projects/foo: unrecognized import path "_/home/user/projects/foo" (import path does not beg
in with hostname)

Additional notes

When removing the symlink, it works fine. Here is a working hierarchy:

tree view

$ tree /home/user
/home/user
├── go
│   └── src
│       └── github.com
│           └── sguillia
│               └── foo
│                   ├── bar
│                   │   └── bar.go
│                   └── main.go
└── projects

find view

/home/user
/home/user/projects
/home/user/go
/home/user/go/src
/home/user/go/src/github.com
/home/user/go/src/github.com/sguillia
/home/user/go/src/github.com/sguillia/foo
/home/user/go/src/github.com/sguillia/foo/bar
/home/user/go/src/github.com/sguillia/foo/bar/bar.go
/home/user/go/src/github.com/sguillia/foo/main.go

I can do go get -d -u . from within /home/user/go/src/github.com/sguillia/foo.

But I believe I should be able to do it also with the previous hierarchy.

Note

Actually I don't care about go updating foo, I can just git pull. I'd like go to update the possible other dependencies of the project, and this bug or unimplemented feature prevents the update of other dependencies whose folder layout is supported.

Best

@toothrot

This comment has been minimized.

Copy link
Contributor

@toothrot toothrot commented Jan 21, 2020

Have you tried using Go Modules? The replace directive supports this flow explicitly.
See https://github.com/golang/go/wiki/Modules#gomod and https://github.com/golang/go/wiki/Modules#when-should-i-use-the-replace-directive

@toothrot toothrot changed the title go get refuses symlinks cmd/go: get error for symlinks in GOPATH Jan 21, 2020
@toothrot toothrot added this to the Backlog milestone Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.