cmd/go: unable to install sub-module with buildmode=shared with go modules but $GOPATH works #37034
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I am trying to compile a project with
-buildmode=shared
. My project has the following file structure:My
go.mod
file:and my
main.go
simply importsexample.com/affan/project/util
and runs some code. Now following this stackoverflow link I am trying to compile my project in a way such that my main binary links to an.so
ofexample.com/affan/project/util
.What did you expect to see?
I expected it to compile a binary and link to an
so
file of my sub-packageWhat did you see instead?
When I run
go install -buildmode=shared -linkshared example.com/affan/project/util
, I get the following:I thought maybe I'm not specifying the path correctly so I tried.
./util
as the final argument as well, but it had the same result.It works with $GOPATH
I removed
go.mod
and copied everything to under$GOPATH/src
with the correct paths. After that running the commands from the above link works perfectly, I get a binary linked to an.so
of my util package just as I expect. So this is definitely something to do with go-modules (or maybe me doing something wrong?)The text was updated successfully, but these errors were encountered: