Changeset View
Changeset View
Standalone View
Standalone View
documentation/content/en/books/porters-handbook/special/chapter.adoc
Show First 20 Lines • Show All 707 Lines • ▼ Show 20 Lines | |||||
=== Building Go Applications | === Building Go Applications | ||||
For ports that use Go, define `USES=go`. Refer to <<uses-go,`go`>> for a list of variables that can be set to control the build process. | For ports that use Go, define `USES=go`. Refer to <<uses-go,`go`>> for a list of variables that can be set to control the build process. | ||||
[[go-ex1]] | [[go-ex1]] | ||||
.Creating a Port for a Go Modules Based Application | .Creating a Port for a Go Modules Based Application | ||||
[example] | [example] | ||||
==== | ==== | ||||
In most cases, it is sufficient to set `GO_MODULE` variable to the value specified by `module` directive in `go.mod`: | |||||
[.programlisting] | |||||
.... | |||||
PORTNAME= hey | |||||
PORTVERSION= 0.1.4 | |||||
DISTVERSIONPREFIX= v | |||||
CATEGORIES= benchmarks | |||||
MAINTAINER= dmgk@FreeBSD.org | |||||
COMMENT= Tiny program that sends some load to a web application | |||||
LICENSE= APACHE20 | |||||
LICENSE_FILE= ${WRKSRC}/LICENSE | |||||
USES= go:modules | |||||
GO_MODULE= github.com/rakyll/hey | |||||
PLIST_FILES= bin/hey | |||||
.include <bsd.port.mk> | |||||
.... | |||||
If the "easy" way is not adequate or more control over dependencies is needed, the full porting process is described below. | |||||
Creating a Go based port is a five stage process. First we need to provide a ports template that fetches the application distribution file: | Creating a Go based port is a five stage process. First we need to provide a ports template that fetches the application distribution file: | ||||
[.programlisting] | [.programlisting] | ||||
.... | .... | ||||
PORTNAME= ghq | PORTNAME= ghq | ||||
DISTVERSIONPREFIX= v | DISTVERSIONPREFIX= v | ||||
DISTVERSION= 0.12.5 | DISTVERSION= 0.12.5 | ||||
CATEGORIES= devel | CATEGORIES= devel | ||||
▲ Show 20 Lines • Show All 3,576 Lines • Show Last 20 Lines |