Hi,

I'd like to know how to vendor binary-only-package using go mod.
I have something working with GOPATH/pkg but starting with Go1.11, I end up 
with this error:

go build github.com/myname/mylib: *missing or invalid binary-only package; 
> expected file ""*

 
Looking at the source code (/usr/lib/go/src/cmd/go/internal/work/exec.go)
So the target (mylib.a) does not exist in the context of modules 
(GOCACHE=on is mandatory with modules starting with Go1.11) since 
GOPATH/pkg is not used

if a.Package.BinaryOnly {
_, err := os.Stat(a.Package.Target)
if err == nil {
a.built = a.Package.Target
a.Target = a.Package.Target
if b.NeedExport {
a.Package.Export = a.Package.Target
}
a.buildID = b.fileHash(a.Package.Target)
a.Package.Stale = false
a.Package.StaleReason = "binary-only package"
return nil
}
a.Package.Stale = true
a.Package.StaleReason = "missing or invalid binary-only package"
if b.IsCmdList {
return nil
}
return fmt.Errorf("*missing or invalid binary-only package; expected file 
%q"*, a.Package.Target)
}

The error appears as soon as I move the project out of GOPATH.

I thought I could hack my way around and use the new cache instead of 
GOPATH/pkg but the thing is that the fingerprint used for the cache entries 
depend on the source file.
But for binary-only-package, the source file has to be different (since 
it's a stub) so I assume the fingerprint will not match...

I've read here <https://golang.org/doc/go1.11#gocache> that Go1.12 will 
"drop" GOPATH/pkg but the thing is I need to have an upgrade/migration plan 
from vendoring GOPATH/pkg binary-only-package to vendoring "go mod" 
binary-only-package.
Do you guys know of a solution ?

Thank you,
Alex

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to