Sample Binary-Only Packages
Go1.7 introduces Binary-Only Packages. This is sample project (named
hello) to create a Binary-Only Pacakage and distribute it as
How to create?
Actual source code is
hello.go in the root directory of this repository. We will not distribute this code.
To create Binary-Only packages, we need prepare 2 files. The one is a special source code file and the other is package binary.
This special source code file is described in doc,
the package must be distributed with a source file not excluded by build constraints and containing a "//go:binary-only-package" comment.
The example of this source code file is in src/github.com/tcnksm/hello/.
Then, build pacakge binary and place it in
$ go build -o pkg/darwin_amd64/github.com/tcnksm/hello.a -x
$ zip -r hello.zip src/* pkg/*
How to distribute?
zip file which doesn't have actual source code.
To use this binary pacakge, just unzip it in
$ unzip hello.zip -d $GOPATH/