From 653e79254a49438b1b7caeebcdba2986a6166336 Mon Sep 17 00:00:00 2001 From: Paul Meyer <49727155+katexochen@users.noreply.github.com> Date: Sun, 21 Jul 2024 11:58:03 +0200 Subject: [PATCH] doc: document deprecation of `buildGoPackage` Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> --- doc/languages-frameworks/go.section.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/languages-frameworks/go.section.md b/doc/languages-frameworks/go.section.md index d98ecb1c0421..b20308c7b4ab 100644 --- a/doc/languages-frameworks/go.section.md +++ b/doc/languages-frameworks/go.section.md @@ -66,6 +66,25 @@ The following is an example expression using `buildGoModule`: The function `buildGoPackage` builds legacy Go programs, not supporting Go modules. +::: {.warning} +`buildGoPackage` is deprecated and will be removed for the 25.05 release. +::: + +### Migrating from `buildGoPackage` to `buildGoModule` {#buildGoPackage-migration} + +Go modules, released 6y ago, are now widely adopted in the ecosystem. +Most upstream projects are using Go modules, and the tooling previously used for dependency management in Go is mostly deprecated, archived or at least unmaintained at this point. + +In case a project doesn't have external dependencies or dependencies are vendored in a way understood by `go mod init`, migration can be done with a few changes in the package. + +- Switch the builder from `buildGoPackage` to `buildGoModule` +- Remove `goPackagePath` and other attributes specific to `buildGoPackage` +- Set `vendorHash = null;` +- Run `go mod init ` in `postPatch` + +In case the package has external dependencies that aren't vendored or the build setup is more complex the upstream source might need to be patched. +Examples for the migration can be found in the [issue tracking migration withing nixpkgs](https://github.com/NixOS/nixpkgs/issues/318069). + ### Example for `buildGoPackage` {#example-for-buildgopackage} In the following is an example expression using `buildGoPackage`, the following arguments are of special significance to the function: