Help creating a Go package Makefile [Paqet]

I’m trying to build a Go package called paqet for my router.

Build proccess on my WorkStation
macchiato@express:~/paqet-master$ ls
cmd  example  go.mod  go.sum  internal  LICENSE  README.md
macchiato@express:~/paqet-master$ cd cmd/
macchiato@express:~/paqet-master/cmd$ ls
dump  iface  main.go  ping  run  secret  version
macchiato@express://paqet-master/cmd$ go build .
go: downloading github.com/spf13/cobra v1.10.2
go: downloading github.com/gopacket/gopacket v1.5.0
go: downloading github.com/goccy/go-yaml v1.19.2
go: downloading github.com/xtaci/kcp-go/v5 v5.6.64
go: downloading golang.org/x/crypto v0.47.0
go: downloading github.com/txthinking/socks5 v0.0.0-20251011041537-5c31f201a10e
go: downloading github.com/spf13/pflag v1.0.10
go: downloading github.com/xtaci/smux v1.5.53
go: downloading github.com/txthinking/runnergroup v0.0.0-20250224021307-5864ffeb65ae
go: downloading github.com/patrickmn/go-cache v2.1.0+incompatible
go: downloading github.com/klauspost/reedsolomon v1.13.0
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/tjfoc/gmsm v1.4.1
go: downloading golang.org/x/net v0.49.0
go: downloading golang.org/x/sys v0.40.0
go: downloading golang.org/x/time v0.14.0
go: downloading github.com/klauspost/cpuid/v2 v2.3.0
# github.com/gopacket/gopacket/pcap
macchiato@express:~/paqet-master/cmd$ ls
cmd  dump  iface  main.go  ping  run  secret  version
macchiato@express:~/paqet-master/cmd$./cmd -h
paqet is a bidirectional packet-level proxy using KCP and raw socket transport with encryption.

Usage:
  paqet [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  dump        A raw packet dumper that logs TCP payloads for a given port.
  help        Help about any command
  iface       Prints available interfaces
  ping        Sends a single raw TCP packet with a custom payload.
  run         Runs the client or server based on the config file.
  secret      Generates a secure, random 32-byte secret key.
  version     Prints the version information

Flags:
  -h, --help   help for paqet

Use "paqet [command] --help" for more information about a command.
macchiato@express:~/paqet-master/cmd$

First attempt at Makefile using another go Makefile project as a reference:

Makefile
include $(TOPDIR)/rules.mk

PKG_NAME:=paqet
PKG_VERSION:=1.0.0-alpha.14
PKG_RELEASE:=1

PKG_SOURCE:=v$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/hanselime/paqet/archive/refs/tags
PKG_HASH:=d217262c24cf1c9760e7693d2bc8be2229b59c53513dc05e9614cfcde36bc92a

PKG_LICENSE:=GPL-2.0

PKG_BUILD_DIR:=$(BUILD_DIR)/paqet-$(PKG_VERSION)

PKG_BUILD_DEPENDS:=golang/host
PKG_BUILD_PARALLEL:=1
PKG_BUILD_FLAGS:=no-mips16


GO_PKG:=github.com/hanselime/paqet
GO_PKG_BUILD_PKG:=$(GO_PKG)/cmd
GO_PKG_LDFLAGS_X:=main.version=$(PKG_VERSION)

include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk


define Package/paqet
  SECTION:=net
  CATEGORY:=Network
  TITLE:=paqet - Transport over Raw Packet
  URL:=https://github.com/hanselime/paqet
  DEPENDS:=$(GO_ARCH_DEPENDS) +libpcap
endef

define Package/paqet/description
  Paqet is a bidirectional Packet-level proxy built using raw sockets in Go.
  It forwards traffic from a local client to a remote server using KCP
  for secure, reliable transport, bypassing the host TCP/IP stack.
endef

define Package/paqet/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/cmd $(1)/usr/bin/paqet
endef

$(eval $(call BuildPackage,paqet))

Placed it under feeds/packages/net/paqet folder in mediatek-filogic snapshot SDK:

./scripts/feeds install paqet
macchiato@express:~/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64$ ./scripts/feeds install paqet
Collecting package info: done
Collecting target info: done
WARNING: Makefile 'package/kernel/linux/Makefile' has a dependency on 'ar3k-firmware', which does not exist
WARNING: Makefile 'package/kernel/linux/Makefile' has a dependency on 'mwifiex-sdio-firmware', which does not exist
WARNING: Makefile 'package/kernel/linux/Makefile' has a dependency on 'eip197-mini-firmware', which does not exist
WARNING: Makefile 'package/kernel/linux/Makefile' has a dependency on 'aeonsemi-as21xxx-firmware', which does not exist
WARNING: Makefile 'package/kernel/linux/Makefile' has a dependency on 'airoha-en8811h-firmware', which does not exist
WARNING: Makefile 'package/kernel/linux/Makefile' has a dependency on 'r8169-firmware', which does not exist
WARNING: Makefile 'package/kernel/linux/Makefile' has a dependency on 'e100-firmware', which does not exist
WARNING: Makefile 'package/kernel/linux/Makefile' has a dependency on 'bnx2-firmware', which does not exist
WARNING: Makefile 'package/kernel/linux/Makefile' has a dependency on 'bnx2x-firmware', which does not exist
WARNING: Makefile 'package/kernel/linux/Makefile' has a dependency on 'kmod-phy-bcm-ns-usb2', which does not exist
WARNING: Makefile 'package/kernel/linux/Makefile' has a dependency on 'edgeport-firmware', which does not exist
WARNING: Makefile 'package/kernel/linux/Makefile' has a dependency on 'r8152-firmware', which does not exist
WARNING: Makefile 'package/kernel/linux/Makefile' has a dependency on 'kmod-phy-bcm-ns-usb3', which does not exist
WARNING: Makefile 'package/kernel/linux/Makefile' has a dependency on 'amdgpu-firmware', which does not exist
WARNING: Makefile 'package/kernel/linux/Makefile' has a dependency on 'i915-firmware-dmc', which does not exist
WARNING: Makefile 'package/kernel/linux/Makefile' has a dependency on 'ivpu-firmware', which does not exist
WARNING: Makefile 'package/kernel/linux/Makefile' has a dependency on 'radeon-firmware', which does not exist
WARNING: Makefile 'package/kernel/linux/Makefile' has a dependency on 'mt7622bt-firmware', which does not exist
Installing package 'paqet' from packages
Installing package 'golang' from packages
Installing package 'golang1.25' from packages
Installing package 'golang-bootstrap' from packages
Installing package 'libpcap' from base
Installing package 'libcrypt-compat' from base
macchiato@express:~/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64$ 

Compiling it fails perfectly:

make package/paqet/compile V=sc
macchiato@express:~/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64$ make package/paqet/compile V=sc
make[2]: Leaving directory '/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/feeds/packages/lang/golang/golang'
time: package/feeds/packages/golang/host-compile#0.28#0.44#0.56
make[2]: Entering directory '/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/feeds/packages/net/paqet'
rm -f /home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/build_dir/target-aarch64_cortex-a53_musl/paqet-1.0.0-alpha.14/.built
touch /home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/build_dir/target-aarch64_cortex-a53_musl/paqet-1.0.0-alpha.14/.built_check
CONFIG_GOLANG_MOD_CACHE_WORLD_READABLE="" GO_BUILD_CACHE_DIR="/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/tmp/go-build" GO_MOD_CACHE_DIR="/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/dl/go-mod-cache" GO_MOD_ARGS="-modcacherw" PATH=/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/staging_dir/hostpkg/lib/go-1.25/bin:/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/bin:/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/bin:/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/bin:/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/bin:/home/macchiato/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin GO_PKG="github.com/hanselime/paqet" GO_INSTALL_EXTRA="" GO_INSTALL_ALL="" GO_SOURCE_ONLY="" GO_BUILD_PKG="github.com/hanselime/paqet/cmd" GO_EXCLUDES="" GO_GO_GENERATE="" GO_INSTALL_BIN_PATH="/usr/bin" BUILD_DIR="/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/build_dir/target-aarch64_cortex-a53_musl/paqet-1.0.0-alpha.14" GO_BUILD_DIR="/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/build_dir/target-aarch64_cortex-a53_musl/paqet-1.0.0-alpha.14/.go_work/build" GO_BUILD_BIN_DIR="/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/build_dir/target-aarch64_cortex-a53_musl/paqet-1.0.0-alpha.14/.go_work/build/bin/linux_arm64" GO_BUILD_DEPENDS_PATH="/usr/share/gocode" GO_BUILD_DEPENDS_SRC="/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/staging_dir/target-aarch64_cortex-a53_musl/usr/share/gocode/src" PATH=/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/staging_dir/hostpkg/lib/go-1.25/bin:/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/bin:/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/bin:/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/bin:/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/bin:/home/macchiato/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin GOOS="linux" GOARCH="arm64" GO386="" GOAMD64="" GOARM="" GOARM64="v8.0" GOMIPS="" GOMIPS64="" GOPPC64="" CGO_ENABLED=1 CC="aarch64-openwrt-linux-musl-gcc" CXX="aarch64-openwrt-linux-musl-g++" CGO_CFLAGS="-Os -pipe -mcpu=cortex-a53 -fno-caller-saves -fno-plt -fhonour-copts -ffile-prefix-map=/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/build_dir/target-aarch64_cortex-a53_musl/paqet-1.0.0-alpha.14=paqet-1.0.0-alpha.14 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -Wl,-z,pack-relative-relocs" CGO_CPPFLAGS="-I/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/usr/include -I/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/include -I/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/include/fortify" CGO_CXXFLAGS="-Os -pipe -mcpu=cortex-a53 -fno-caller-saves -fno-plt -fhonour-copts -ffile-prefix-map=/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/build_dir/target-aarch64_cortex-a53_musl/paqet-1.0.0-alpha.14=paqet-1.0.0-alpha.14 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -Wl,-z,pack-relative-relocs" CGO_LDFLAGS="-L/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/usr/lib -L/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/lib -fuse-ld=bfd -znow -zrelro -zpack-relative-relocs" GOPATH="/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/build_dir/target-aarch64_cortex-a53_musl/paqet-1.0.0-alpha.14/.go_work/build" GOCACHE="/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/tmp/go-build" GOMODCACHE="/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/dl/go-mod-cache" GOENV=off GOTOOLCHAIN=local /usr/bin/env bash /home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/feeds/packages/lang/golang/golang-build.sh build -v -buildvcs=false -trimpath -ldflags "all=-buildid '1770247201' -linkmode external -extldflags '-L/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/usr/lib -L/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/lib -fuse-ld=bfd -Wl,-z,now -Wl,-z,relro -Wl,-z,pack-relative-relocs'"      -installsuffix "v8.0"    -ldflags " -X main.version=1.0.0-alpha.14 -buildid '1770247201' -linkmode external -extldflags '-L/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/usr/lib -L/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/lib -fuse-ld=bfd -Wl,-z,now -Wl,-z,relro -Wl,-z,pack-relative-relocs'"  
Finding targets
no required module provides package github.com/hanselime/paqet/cmd; to add it:
        go get github.com/hanselime/paqet/cmd

Building targets
no Go files in /home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/build_dir/target-aarch64_cortex-a53_musl/paqet-1.0.0-alpha.14/.go_work/build

make[2]: *** [Makefile:52: /home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/build_dir/target-aarch64_cortex-a53_musl/paqet-1.0.0-alpha.14/.built] Error 1
make[2]: Leaving directory '/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/feeds/packages/net/paqet'
time: package/feeds/packages/paqet/compile#0.47#0.80#0.99
    ERROR: package/feeds/packages/paqet failed to build.
make[1]: *** [package/Makefile:187: package/feeds/packages/paqet/compile] Error 1
make[1]: Leaving directory '/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64'
make: *** [/home/macchiato/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/include/toplevel.mk:226: package/paqet/compile] Error 2
macchiato@express:~/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64$ 

Look at other packages:

- GO_PKG:=github.com/hanselime/paqet
- GO_PKG_BUILD_PKG:=$(GO_PKG)/cmd
+ GO_PKG:=paqet

PKG_VERSION format is invalid.

It Worked :tada: ! Thank you !

I think I hacked my way through but I’d like to know whether it is an acceptable approach for these situations?

PKG_NAME:=paqet
PKG_VERSION:=1.0.0
PKG_RELEASE:=1

PKG_SOURCE:=v$(PKG_VERSION)-alpha.14.tar.gz
PKG_SOURCE_URL:=https://github.com/hanselime/paqet/archive/refs/tags

If you're not planning to add this to the package feed, then it doesn't matter. I wouldn't accept an alpha version package either way. Aside from that, I'd declare separate package and source version variables.

And don't forget to mark this topic as solved, if you feel your question has been sufficiently addressed.