Package Details: speedtest-go 1.7.10-1

Git Clone URL: https://aur.archlinux.org/speedtest-go.git (read-only, click to copy)
Package Base: speedtest-go
Description: CLI and Go API to Test Internet Speed using speedtest.net
Upstream URL: https://github.com/showwin/speedtest-go
Licenses: MIT
Conflicts: speedtest-go
Provides: speedtest-go
Submitter: abdulocracy
Maintainer: abdulocracy
Last Packager: abdulocracy
Votes: 8
Popularity: 0.026091
First Submitted: 2022-12-18 14:23 (UTC)
Last Updated: 2024-12-22 14:30 (UTC)

Latest Comments

albeec13 commented on 2025-05-09 19:37 (UTC) (edited on 2025-05-09 20:12 (UTC) by albeec13)

Hello, I would like to request the following changes to this PKGBUILD:

diff --git a/PKGBUILD b/PKGBUILD
index a998091..86c859f 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -22,7 +22,19 @@ build ()
   export CGO_CFLAGS="${CFLAGS}"
   export CGO_CXXFLAGS="${CXXFLAGS}"
   export CGO_LDFLAGS="${LDFLAGS}"
-  export GOFLAGS='-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw'
+
+  # use external linkage only if building debug package
+  if [[ " ${OPTIONS[@]} " =~ " debug " ]]; then
+    echo "DEBUG is enabled"
+    export GOFLAGS='-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw'
+  else
+    echo "DEBUG is NOT enabled"
+    export GOFLAGS='-buildmode=pie -trimpath -mod=readonly -modcacherw'
+  fi
+
+  # store Go modules in local build path to avoid polluting user/global modules path
+  export GOMODCACHE="$(pwd)/.gomodcache"
+
   go build
 }

Building with -ldflags=-linkmode=external is only required if building debug packages by the Arch PKGBUILD guidelines for Go packages, and will fail like so without additional dependencies:

-linkmode=external requires external (cgo) linking, but cgo is not enabled
==> ERROR: A failure occurred in build().
Aborting...

The addtion of export GOMODCACHE="$(pwd)/.gomodcache" ensures that mmodule dependencies for the speedtest-go package are downloaded to the build path instead of the user/global module path, to avoid polluting them with dependencies that won't be uninstalled automatically after this package is built.

Thanks!