GO-MODULE(5)
πΉ go-module(5) β the lang/go port module, explained bestie to bestie
okay so this is from the File Formats Manual section of the man pages (yes, go-module(5), that's her full name π
) and it's literally the entire personality of setting MODULES=lang/go in the ports(7) tree. Buckle up π
β¨ NAME β¨
go-module β the lang/go port module. that's it, that's the whole name, she's iconic like that π
πΈ DESCRIPTION πΈ
This page documents exactly what happens when you set MODULES=lang/go in the ports(7) tree. no cap, every detail is here π«Ά
π¦ What it actually does
It adds Go toolchain support. periodt. and it requires ALL_TARGET to be set to the canonical Go import path of the port. (good news tho: the module sets it automatically for ports that use the GH_ACCOUNT and GH_PROJECT macros, so you don't gotta do it yourself π)
π The build pipeline, step by step
- During
pre-configureβ the module moves the source code from${MODGO_SUBDIR}to${WRKSRC}, which is a subdirectory of${MODGO_WORKSPACE}β a specially-crafted Go workspace located at${WRKDIR}/go. moving day! π - During
do-buildβ the module callsgo installwithGOPATHset to${MODGO_WORKSPACE}, runs its output throughsedto prevent writes outside theWRKDIRsandbox, and sends the output tosh(1). the sed glow-up is doing SO much work here ngl β¨ - During
do-installβ it copies executables from${MODGO_WORKSPACE}/binto${PREFIX}/bin, and/or the directories${MODGO_WORKSPACE}/pkgand${MODGO_WORKSPACE}/srcto${PREFIX}/go, all depending on what's inMODGO_TYPE. it's giving "choose your own adventure" π§
β Stuff it sets for you
It sets BUILD_DEPENDS, RUN_DEPENDS, ALL_TARGET, TEST_TARGET, ONLY_FOR_ARCHS, SEPARATE_BUILD, and WRKSRC. so many presets, so little effort from you π
It also appends to CATEGORIES.
π The variables it defines π
MODGO_TYPEβ the type of port. can be any combination of:binβ an ordinary binary, which should be installed to${PREFIX}/binlibβ a library, which should come with source code- defaults to
bin. simple, classic, reliable π
MODGO_WORKSPACEβ path to the Go workspace set up for the port build process. defaults to${WRKDIR}/go. see the Go documentation for details, iykyk πMODGO_SUBDIRβ path to the Go source code within the port's sources tarball. defaults to${WRKDIST}.MODGO_SETUP_WORKSPACEβ the commands that set up the Go workspace for building ports. by default this happens during execution of thepre-configuretarget.MODGO_BUILDDEPβ controls whether the contents ofMODGO_BUILD_DEPENDSget appended to the port'sBUILD_DEPENDS. defaults toYesβMODGO_MODNAMEβ the name of the Go module as defined in thego.modfile contained in the project. > if this is set,MODGO_MODULES,MODGO_MODFILESandMODGO_VERSIONneed to be defined as well β all four or nothing bestie, no skipping π€ Setting this will also setALL_TARGET. and whenMODGO_MODFILESis set and a"cmd"directory is found inWRKSRC, then"./cmd/..."is also built bydo-buildautomatically. sneak attack build π₯MODGO_VERSIONβ sets the specific version of a Go module to use. for example:v0.1.3.MODGO_MODULESβ the list of modules and their specific versions that an application depends on.MODGO_MODFILESβ the list ofgo.modfiles and their versions that are required for dependency resolution. these are required by Go to determine the full dependency graph β like, mandatory mandatory π«Ά
π And there's more (the bonus round)
Additionally it defines:
MODGO_ARCHβ application architecture name used by GoMODGO_PACKAGES,MODGO_SOURCESandMODGO_TOOLSβ paths for installed Go packages, sources and tools respectivelyMODGO_CMDandMODGO_FLAGSβ the source code build command and the flags passed as its argumentsMODGO_LDFLAGSMODGO_BUILD_CMDandMODGO_TEST_CMDβ commands for building and testing go packages; normally called with canonical Go package names as argumentsMODGO_{BUILD,INSTALL,TEST}_TARGETMODGO_{BUILD,RUN}_DEPENDS
the curly braces are literally serving cunt, she's efficient πβ¨
π The make(1) target π
This module adds exactly one make(1) target:
modgo-gen-modulesβ generate theMODGO_MODULESand theMODGO_MODFILESlists. ifMODGO_VERSIONis set to"latest", the latest known-to-Go version of a package will be used to build the list of modules. similarly, ifMODGO_VERSIONis empty, the latest version will be fetched. auto-magic, we love to see it β
π SEE ALSO π
port-modules(5)β go read that one next, bestie, it's the whole family π¦
friendly reminder that this is a real build system and the sandbox rules are there for a reason β thesedwrite-prevention step is not decorative, it's literally protecting yourWRKDIR. respect the sandbox π
πΈ aaaand that's the page! this cutie comes to you courtesy of Debian, dated February 7, 2025 β she's fresh, she's official, she's slaying. bye bestie, happy porting π ππ
π¦ where this page comes from
- nixpkgs unstable: cvs-export
- Copyright (c) 2008 Marc Espie
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms