The Go plugin integrates projects written in Go. This plugin uses the common plugin keywords as well as those for sources. For more information, see Snapcraft parts metadata.
Plugin-specific features and syntax are dependent on which base is being used, as outlined below:
See Go applications for a simple example, or search GitHub for projects already using the plugin.
ⓘ This is a snapcraft plugin. See Snapcraft plugins and Supported plugins for further details on how plugins are used.
base: core24 | core22
The go plugin in core22 exclusively requires the use of go.mod.
Additionally, the build environment does not include go by default. To install the latest version, add go to a build-snaps section for the part:
build-snaps:
- go
This plugin uses the following plugin-specific keywords:
go-buildtags(list of strings) Tags to use during the go build. Default is not to use any build tags.
Requires Snapcraft version 7.0+.
base: core20
The go plugin in core20 exclusively requires the use of go.mod.
This plugin uses the following plugin-specific keywords:
-
go-channel(string, default: latest/stable) The snap Store channel to install go from. If set to an empty string, go will be installed using the system’s traditional package manager. -
go-buildtags(list of strings) Tags to use during the go build. Default is not to use any build tags.
Requires Snapcraft version 4.0+.
base: core18 | core
The go plugin support in core and core18 can be used by Go projects using go get, the command used to grab a project’s dependencies or go mod.
This plugin uses the following plugin-specific keywords:
-
go-channel(string, default: latest/stable) The snap Store channel to install go from. If set to an empty string, go will be installed using the system’s traditional package manager. -
go-packages(list of strings) Go packages to fetch, these must be a “main” package. Dependencies are pulled in automatically bygo get. Packages that are not “main” will not cause an error, but would not be useful either. If the package is a part of the go-importpath the local package
corresponding to those sources will be used -
go-importpath(string) This entry tells the checked outsourceto live within a certain path
withinGOPATH. This is not needed and does not affectgo-packages. -
go-buildtags(list of strings) Tags to use during the go build. Default is not to use any build tags.
Requires Snapcraft version 3.x.
