1.\" $OpenBSD: go-module.5,v 1.1 2021/02/25 09:13:18 espie Exp $ 2.\" 3.\" Copyright (c) 2008 Marc Espie 4.\" 5.\" All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 17.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 20.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26.\" 27.Dd $Mdocdate: February 25 2021 $ 28.Dt GO-MODULE 5 29.Os 30.Sh NAME 31.Nm go-module 32.Nd lang/go port module 33.Sh DESCRIPTION 34This manual page documents the behavior of setting 35.Li MODULE=lang/go 36in the 37.Xr ports 7 38tree. 39.Pp 40Adds Go toolchain support. 41Requires 42.Ev ALL_TARGET 43to be set to canonical Go import path of port. 44(Module sets it automatically for ports that use 45.Ev GH_ACCOUNT 46and 47.Ev GH_PROJECT 48macros.) 49.Pp 50During execution of 51.Cm pre-configure 52target module moves source code from 53.Pa ${MODGO_SUBDIR} 54to 55.Pa ${WRKSRC} , 56subdirectory of 57.Pa ${MODGO_WORKSPACE} 58- specially-crafted Go workspace located at 59.Pa ${WRKDIR}/go . 60During 61.Cm do-build 62module calls 63.Dq go install 64with 65.Ev GOPATH 66set to 67.Pa ${MODGO_WORKSPACE} , 68runs its output through sed to prevent writes outside 69.Ev WRKDIR 70sandbox and sends output to 71.Xr sh 1 . 72During 73.Cm do-install 74it copies executables from 75.Pa ${MODGO_WORKSPACE}/bin 76to 77.Pa ${PREFIX}/bin , 78and/or directories 79.Pa ${MODGO_WORKSPACE}/pkg 80and 81.Pa ${MODGO_WORKSPACE}/src 82to 83.Pa ${PREFIX}/go , 84depending on 85.Ev MODGO_TYPE 86contents. 87.Pp 88Sets 89.Ev BUILD_DEPENDS , 90.Ev RUN_DEPENDS , 91.Ev ALL_TARGET , 92.Ev TEST_TARGET , 93.Ev ONLY_FOR_ARCHS , 94.Ev SEPARATE_BUILD , 95and 96.Ev WRKSRC . 97.Pp 98Appends to 99.Ev CATEGORIES . 100.Pp 101Defines: 102.Bl -tag -width MODGO_WORKSPACE 103.It Ev MODGO_TYPE 104Type of port. 105May be any combination of: 106.Bl -tag -width lib 107.It bin 108ordinary binary, which should be installed to 109.Pa ${PREFIX}/bin , 110.It lib 111library, which should come with source code. 112.El 113.Pp 114Defaults to 115.Ar bin . 116.It Ev MODGO_WORKSPACE 117Path to Go workspace set up for port build process. 118Defaults to 119.Pa ${WRKDIR}/go . 120See Go documentation for details. 121.It Ev MODGO_SUBDIR 122Path to Go source code within port's sources tarball. 123Defaults to 124.Pa ${WRKDIST} . 125.It Ev MODGO_SETUP_WORKSPACE 126Commands setting up Go workspace for building ports. 127By default, happens during execution of 128.Cm pre-configure 129target. 130.It Ev MODGO_BUILDDEP 131Controls whether contents of 132.Ev MODGO_BUILD_DEPENDS 133are appended to port's 134.Ev BUILD_DEPENDS . 135Defaults to 136.Ar Yes . 137.It Ev MODGO_MODNAME 138is the module name as defined in the 139.Pa go.mod 140file contained in a project. 141If this is set, 142.Ev MODGO_MODULES , 143.Ev MODGO_MODFILES 144and 145.Ev MODGO_VERSION 146need to be defined as well. 147Setting this will also set 148.Ev ALL_TARGET . 149When 150.Ev MODGO_MODFILES 151is set, and a "cmd" directory is found in 152.Ev WRKSRC , 153"cmd/..." is appended to 154.Ev ALL_TARGET 155in 156.Cm do-build 157automatically. 158.It Ev MODGO_VERSION 159Sets the specific version of a Go module to use. 160For example: v0.1.3. 161.It Ev MODGO_MODULES 162List of modules and their specific versions that an application depends on. 163.It Ev MODGO_MODFILES 164List of go.mod files and their versions that are required for dependency 165resolution. 166These are required by Go to determine the full dependency graph. 167.El 168.Pp 169Additionally defines 170.Ev MODGO_PACKAGES , 171.Ev MODGO_SOURCES 172and 173.Ev MODGO_TOOLS 174(paths for installed Go packages, sources and tools respectively), 175.Ev MODGO_CMD 176and 177.Ev MODGO_FLAGS 178(source code build command and flags passed as its arguments), 179.Ev MODGO_LDFLAGS , 180.Ev MODGO_BUILD_CMD 181and 182.Ev MODGO_TEST_CMD 183(commands for building and testing go packages; normally called with canonical 184Go package names as arguments), 185.Ev MODGO_{BUILD,INSTALL,TEST}_TARGET 186and 187.Ev MODGO_{BUILD,RUN}_DEPENDS . 188.Pp 189This module adds one 190.Xr make 1 191target: 192.Bl -tag -width modgo-gen-modules 193.It Cm modgo-gen-modules 194Generate the 195.Ev MODGO_MODULES 196and the 197.Ev MODGO_MODFILES 198lists. 199.El 200.Sh SEE ALSO 201.Xr port-modules 5 202