go-binary-only-package icon indicating copy to clipboard operation
go-binary-only-package copied to clipboard

Doesn't work

Open bnjjj opened this issue 8 years ago • 6 comments

I follow your readme step by step in order to use my binary golang package into another project. So for example I have a project called test and I want to use hello package in test so I have made your readme instructions but here is the answer in my terminal :

main.go:9:2: cannot find package "hello" in any of:
	$GOPATH/src/github.com/bnjjj/go_api/vendor/hello (vendor tree)
	/usr/local/Cellar/go/1.7.1/libexec/src/hello (from $GOROOT)
	$GOPATH/src/hello (from $GOPATH)

Any idea ?

bnjjj avatar Nov 14 '16 21:11 bnjjj

@bnjjj I think you just clone this project and does't change the name of it. You should rename it to hello. Thank you for the author's example. I have made a deploy script for golang-binary-package-generator. If you don't mind, please use it, which will satisfy you.

atlas-comstock avatar Nov 15 '16 10:11 atlas-comstock

Alright so I have download your project in order to try. First my .a is generated here $GOPATH/pkg/darwin_amd64/go-api ( $GOPATH/pkg/darwin_amd64/go-api/blackbox.a) My project when I want to import my package compiled in .a is in $GOPATH/src/github.com/bnjjj/go_api

In my project ($GOPATH/src/github.com/bnjjj/go_api) I have my .go file with the //go:binary-only-package comment. For example :

//go:binary-only-package

package blackbox

in $GOPATH/src/github.com/bnjjj/go_api/blackbox/blackbox.go

and when I launch go run main.go

I'm getting an error like this:

main.go:9:2: cannot find package "go_api/blackbox" in any of:
    $GOPATH/src/github.com/bnjjj/go_api/vendor/go_api/blackbox (vendor tree)
    /usr/local/Cellar/go/1.7.1/libexec/src/go_api/blackbox (from $GOROOT)
    $GOPATH/src/go_api/blackbox (from $GOPATH)

Where am I wrong please :( ?

bnjjj avatar Nov 15 '16 13:11 bnjjj

@bnjjj Where is your main.go? Does it separated from your go_api? You can have a look on my example directory struct.

atlas-comstock avatar Nov 15 '16 15:11 atlas-comstock

No it's inside my go_api

bnjjj avatar Nov 15 '16 15:11 bnjjj

@bnjjj Make sure that your main.go can not use the package name as go_api, it must has a unique package name.

atlas-comstock avatar Nov 15 '16 17:11 atlas-comstock

Ok ! It's good I've found my error. Here is an improvement https://github.com/YongHaoWu/golang-binary-package-generator/pull/1

bnjjj avatar Nov 15 '16 19:11 bnjjj