17.33. go

Important:

Ports should not be created for Go libs, see Section 6.29, “Go Libraries” for more information.

Possible arguments: (none), modules, no_targets, run

Sets default values and targets used to build Go software. A build dependency on the Go compiler port selected via GO_PORT is added. By default the build is performed in GOPATH mode. If Go software uses modules, the modules-aware mode can be switched on with modules argument. no_targets will setup build environment like GO_ENV, GO_BUILDFLAGS but skip creating post-extract, do-build and do-install targets. run will also add a run dependency on what is in GO_PORT.

The build process is controlled by several variables:

GO_PKGNAME

The name of the Go package. When building in GOPATH mode, this is the directory that will be created in ${GOPATH}/src and seen by the go. When building in modules-aware mode, no GOPATH directories will be created and GO_PKGNAME value will be only used as a default for GO_TARGET. If not set explicitly and GH_SUBDIR is present, GO_PKGNAME value will be inferred from ${GH_SUBDIR}, otherwise it will be set to ${PORTNAME}.

GO_TARGET

The name of the packages to build. The default value is ${GO_PKGNAME}.

CGO_CFLAGS

Additional CFLAGS values to be passed to the C compiler by go.

CGO_LDFLAGS

Additional LDFLAGS values to be passed to the C compiler by go.

GO_BUILDFLAGS

Additional build arguments to be passed to go install.

GO_PORT

The Go compiler port to use. By default this is lang/go but can be set to lang/go-devel in make.conf for testing with future Go versions.

Warning:

This variable must not be set by individual ports!

See Section 6.5.8, “Building Go Applications” for usage examples.

All FreeBSD documents are available for download at https://download.freebsd.org/ftp/doc/

Questions that are not answered by the documentation may be sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.