Sample of Go1.7 Binary-Only Packages
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

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 zip file.

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/

Then, build pacakge binary and place it in pkg/darwin_amd64/ directory.

$ go build -o pkg/darwin_amd64/ -x

Finally, zip src and pkg directory,

$ zip -r src/* pkg/*

How to distribute?

Share above zip file which doesn't have actual source code.

To use this binary pacakge, just unzip it in $GOPATH,

$ unzip -d $GOPATH/