---
name: "go-module"
section: "5"
platform: "openbsd"
package: "man"
version: "8.0-current-20261101"
release: "OpenBSD 8.0-current (2026-11-01)"
platforms: ["openbsd"]
url: "https://new.carta.tech/go-module"
---

# go-module(5)

lang/go port module

## NAME

**go-module** – lang/go port module

## DESCRIPTION

This manual page documents the behavior of setting MODULES=lang/go in the [ports(7)](/ports/7.md) tree.

Adds Go toolchain support. Requires ALL\_TARGET to be set to canonical Go import path of port. (Module sets it automatically for ports that use GH\_ACCOUNT and GH\_PROJECT macros.)

During execution of **pre-configure** target module moves source code from *${MODGO\_SUBDIR}* to *${WRKSRC}*, subdirectory of *${MODGO\_WORKSPACE}* - specially-crafted Go workspace located at *${WRKDIR}/go*. During **do-build** module calls “go install” with GOPATH set to *${MODGO\_WORKSPACE}*, runs its output through sed to prevent writes outside WRKDIR sandbox and sends output to [sh(1)](/sh/1.md). During **do-install** it copies executables from *${MODGO\_WORKSPACE}/bin* to *${PREFIX}/bin*, and/or directories *${MODGO\_WORKSPACE}/pkg* and *${MODGO\_WORKSPACE}/src* to *${PREFIX}/go*, depending on MODGO\_TYPE contents.

Sets BUILD\_DEPENDS, RUN\_DEPENDS, ALL\_TARGET, TEST\_TARGET, ONLY\_FOR\_ARCHS, SEPARATE\_BUILD, and WRKSRC.

Appends to CATEGORIES.

Defines:

- MODGO\_TYPE

  Type of port. May be any combination of:

  - bin

    ordinary binary, which should be installed to *${PREFIX}/bin*,

  - lib

    library, which should come with source code.

    Defaults to *bin*.

- MODGO\_WORKSPACE

  Path to Go workspace set up for port build process. Defaults to *${WRKDIR}/go*. See Go documentation for details.

- MODGO\_SUBDIR

  Path to Go source code within port's sources tarball. Defaults to *${WRKDIST}*.

- MODGO\_SETUP\_WORKSPACE

  Commands setting up Go workspace for building ports. By default, happens during execution of **pre-configure** target.

- MODGO\_BUILDDEP

  Controls whether contents of MODGO\_BUILD\_DEPENDS are appended to port's BUILD\_DEPENDS. Defaults to *Yes*.

- MODGO\_MODNAME

  Name of Go module as defined in the *go.mod* file contained in a project. If this is set, MODGO\_MODULES, MODGO\_MODFILES and MODGO\_VERSION need to be defined as well. Setting this will also set ALL\_TARGET. When MODGO\_MODFILES is set, and a "cmd" directory is found in WRKSRC, "./cmd/..." is also built by **do-build** automatically.

- MODGO\_VERSION

  Sets the specific version of a Go module to use. For example: v0.1.3.

- MODGO\_MODULES

  List of modules and their specific versions that an application depends on.

- MODGO\_MODFILES

  List of go.mod files and their versions that are required for dependency resolution. These are required by Go to determine the full dependency graph.

Additionally defines MODGO\_ARCH (application architecture name used by Go), MODGO\_PACKAGES, MODGO\_SOURCES and MODGO\_TOOLS (paths for installed Go packages, sources and tools respectively), MODGO\_CMD and MODGO\_FLAGS (source code build command and flags passed as its arguments), MODGO\_LDFLAGS, MODGO\_BUILD\_CMD and MODGO\_TEST\_CMD (commands for building and testing go packages; normally called with canonical Go package names as arguments), MODGO\_{BUILD,INSTALL,TEST}\_TARGET and MODGO\_{BUILD,RUN}\_DEPENDS.

This module adds one [make(1)](/make/1.md) target:

- **modgo-gen-modules**

  Generate the MODGO\_MODULES and the MODGO\_MODFILES lists. If MODGO\_VERSION is set to "latest", the latest known-to-Go version of a package will be used to build the list of modules. Similarly, if MODGO\_VERSION is empty, the latest version will be fetched.

## SEE ALSO

[port-modules(5)](/port-modules/5.md)
