The golang PortGroup allows for efficient porting of Go-based open source software.
This PortGroup greatly simplifies the porting of software written in Go, especially when the software and its dependencies are hosted on GitHub or Bitbucket. Provided a project author follows common Go packaging practices, a port can be almost fully configured simply by declaring the package identifier.
In particular, Go has strict requirements relating to the arrangement of code on the filesystem (GOPATH). This PortGroup handles the construction of the GOPATH for you.
The main port configuration is triggered by the usage of the go.setup keyword:
PortGroup golang 1.0 go.setup domain/author/project version [tag_prefix] [tag_suffix]
By default, the port name will be set to the package name (+project+) and version will be set to the project +version+.
The port name can be overridden by using the name keyword.
The tag_prefix and tag_suffix are optional, and are used to specify a prefix/suffix to use when constructing the tag name.
If, for example, the project uses tags such as +v1.0.0+, then the tag_prefix should be set to +v+, as in the following example:
go.setup domain/author/project version v
When the domain is either github.com or +bitbucket.org+, the appropriate PortGroup will be applied and set up automatically.
See those PortGroups' documentation for details.
Projects hosted elsewhere can be used, but require additional manual setup.
The PortGroup provides a keyword to facilitate listing dependencies: +go.vendors+.
Supply a list of vendor package IDs, their versions (git commit hashes, labeled "lock" as in "lockfile"), and their checksums as follows.
The packages and their versions can usually be found in a lockfile (e.g. Gopkg.lock, glide.lock) in the upstream code.
All checksum types supported by the <<reference.phases.checksum,checksums>> keyword are supported here as well.
go.vendors example.com/dep1/foo \
lock abcdef123456... \
rmd160 fedcba654321... \
sha256 bdface246135... \
size 1234 \
example.com/dep2/bar \
lock abcdef123456... \
rmd160 fedcba654321... \
sha256 bdface246135... \
size 4321Note that go.vendors cannot be used with dependencies hosted outside of GitHub and Bitbucket.
Such dependencies must be handled manually.
After the extraction phase, the vendor packages will be placed alongside the main port code as appropriate in the GOPATH.
By default this PortGroup runs go build from the +${worksrcpath}+.
Assuming this results in a binary with the same name as the project, and that there are no other files to install, the following is sufficient for the destroot phase:
destroot {
xinstall -m 755 ${worksrcpath}/${name} ${destroot}${prefix}/bin/
}Please modify as appropriate for each individual port.
When the golang PortGroup is declared within a Portfile, the following variables are provided during port install.
Default: ${prefix}/bin/go
The Go binary location.
+example.com/author/project+.+${go.package}+.Default: +${workpath}+/gopath
The location where source packages will be arranged after the extract phase.
${build_arch}${os.platform}Portfiles using PortGroup golang do not need to define the following variables:
Default: darwin freebsd linux
Go can target these platforms, but individual ports should override this as necessary if only some are actually supported.
${go.bin} build+${gopath}+ GOARCH=+${goarch}+ GOOS=+${goos}+ CC=+${configure.cc}+