Skip to content

tcnksm/go-binary-only-package

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

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.

https://tip.golang.org/pkg/go/build/#hdr-Binary_Only_Packages

The example of this source code file is in src/github.com/tcnksm/hello/.

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

$ go build -o pkg/darwin_amd64/github.com/tcnksm/hello.a -x

Finally, zip src and pkg directory,

$ zip -r hello.zip 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 hello.zip -d $GOPATH/

About

Sample of Go1.7 Binary-Only Packages

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages