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: no place to install binary-only packages in module mode #28146

Closed
oszika opened this issue Oct 11, 2018 · 4 comments
Closed

cmd/go: no place to install binary-only packages in module mode #28146

oszika opened this issue Oct 11, 2018 · 4 comments
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@oszika
Copy link

oszika commented Oct 11, 2018

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

$ go version
go version go1.11 linux/amd64

Does this issue reproduce with the latest release?

Yes with Go1.11.1

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

$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/oszika/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/oszika/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/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-build421177302=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I want to vendor binary-only-package using go mod.

What did you expect to see?

First, I have written the package to expose as binary-only :

package p1

import "fmt"

func F() { fmt.Println("") }

After build it, I have added //go:binary-only-package but build does not work anymore : go build p1: missing or invalid binary-only package; expected file "".
But it's normal, because there is no target using go mod. Futhermore, using p1 in another package returns the same error.

So, I have produced a library like that : go build -o p1.a. But I do not know where to put my library because $GOPATH/pkg is not used. And go mod vendor makes vendored copy of source only.

What did you see instead?

$GOPATH/pkg will be eliminated at next version. Is there a solution like binary-only-package?

Workaround

To workaround this trouble, I have used $GOROOT/pkg, but I think it's ugly.

@bcmills bcmills changed the title binary-only-package not working using go mod cmd/go: no place to install binary-only packages in module mode Oct 11, 2018
@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 11, 2018
@bcmills bcmills added this to the Go1.12 milestone Oct 11, 2018
@rsc
Copy link
Contributor

rsc commented Oct 11, 2018

In general binary-only packages are not too well supported, by design. In particular "go get" has never supported them. The assumption is that the binary distribution is happening in some other way. I am not 100% sure we need to keep them working at all. Perhaps we should admit defeat and just drop support for them entirely.

That said, it seems OK to look in GOPATH/pkg for the .a file for a binary-only package as a stop-gap.

@oszika
Copy link
Author

oszika commented Oct 11, 2018

Thank you for your response.

Indeed, binary-only-package seems to be hard to support.
Do you have an idea for another approach to provide a SDK?

@rsc
Copy link
Contributor

rsc commented Nov 20, 2018

@oszika, I would provide source code. That's what is guaranteed to work with all possible compilation settings.

@rsc
Copy link
Contributor

rsc commented Nov 20, 2018

Given the plan to remove binary-only packages (#28152) I don't think we need to make them module-compatible before removing them. Let's leave this alone.

@rsc rsc closed this as completed Nov 20, 2018
@golang golang locked and limited conversation to collaborators Nov 20, 2019
@rsc rsc unassigned bcmills Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants