gotar is a drop-in replacement for
go build that also includes any static
go install github.com/ConradIrwin/gotar
Instead of running
go build, run
gotar. That's it!
You can continue to use
$GOARCH to control cross-compilation as normal.
No changes to your app code are required unless you rely on the working directory. See Notes.
gotar works by creating a self-extracting tar file with your app in it. When the gotar app is run it:
- exports the current working directory to the
- creates a temporary directory (and exports as
- cds into
- untars all of your files
- execs your app.
If your app doesn't depend on its working directory (e.g. servers) then this
will work flawlessly. However if you need access to the working directory you
now need to access it via
os.Getenv("GOTAR_PWD") instead of
The current implementation creates a new temporary directory each time the
application is run. You can run
rm -r $GOTAR_DIR when your app quits to
reclaim this space.
By default gotar will include the entire current directory and all subdirectories.
If you only want a subset of your files to be included, list them in a
at the top level. This file consists of several patterns, one per line. If the pattern
** then it will match all files in the specified directories and subdirectories.Otherwise the pattern is passed to
gotar is licensed under the MIT license (see LICENSE.MIT). Contributions and bug reports are welcome.