Go
The Deploio build environment makes use of the Paketo Go buildpack.
Example App
We have a basic Go app in our examples repository. You can deploy it with nctl
:
nctl create application go \
--git-url=https://github.com/ninech/deploio-examples \
--git-sub-path=go
Build env considerations
The build process offers a few env variables to adjus it to your use-case. See the how to section of the documentation for all available variables.
Specify your main.go path
By default, the Go buildpack will compile the package in the repository root
directory. If your main.go
is in a different directory, e.g.
cmd/web/main.go
, you need to specify the path using the build env variable
BP_GO_TARGETS="./cmd/web"
.
It's also possible to build multiple packages (binaries) into your app by using a colon-delimited list
--build-env=BP_GO_TARGETS="./first:./second"
Keeping source files
By default, the build output only contains the Go binaries and all source code is removed. If you want to keep specific files or directories, you can specify them using BP_KEEP_FILES
:
--build-env=BP_KEEP_FILES="assets/*:public/*"
Another way to keep static assets which does not require any special env
vars is to directly embed them into the Go binary using the embed
package.