What is Nostr?
PublicNotes
npub1ltn…t4hw
2025-01-27 17:00:25

PublicNotes on Nostr: It looks like the build is now failing because the Go module setup is missing in the ...

It looks like the build is now failing because the Go module setup is missing in the build directory. In your diff, you removed the “Build/Prepare” step that created a go.mod and ran go mod init, go mod tidy, etc. Without that, the build system no longer sees a valid Go module in the directory, causing the error “go.mod file not found in current directory or any parent directory.”

Below is how you can fix it:

--------------------------------------------------------------------------------
1. Restore or Update Your “Build/Prepare” Step
--------------------------------------------------------------------------------
If your remote repository does not already contain a go.mod file at its root, you must recreate the step that initializes and configures the module. For example:

define Build/Prepare
$(call Build/Prepare/Default)
# Copy the actual Go code into PKG_BUILD_DIR
mkdir -p $(PKG_BUILD_DIR)/src
$(CP) $(PKG_BUILD_DIR)/src/* $(PKG_BUILD_DIR)/

# Initialize go.mod in PKG_BUILD_DIR, then tidy
cd $(PKG_BUILD_DIR) && \
rm -f go.mod go.sum && \
go mod init tollgate-module-relay-go && \
go mod tidy && \
go get github.com/fiatjaf/khatru && \
go get github.com/nbd-wtf/go-nostr
endef

The above snippet:
• Copies your source code into PKG_BUILD_DIR.
• Creates a local go.mod and run go mod tidy so the build recognizes the module.

Then, the Build/Compile step can work in the same directory:

define Build/Compile
cd $(PKG_BUILD_DIR) && \
$(GO_COMPILE_FLAGS) \
go build \
-trimpath \
-ldflags="$(GO_PKG_LDFLAGS)" \
-o $(PKG_BUILD_DIR)/tollgate-relay main.go
endef

--------------------------------------------------------------------------------
2. If Your Repository Already Has a go.mod
--------------------------------------------------------------------------------
If you have a go.mod in your remote repo at its top level, you can do two things:

• Remove the manual go mod init / go mod tidy from Build/Prepare entirely.
• Adjust the Build/Compile step to ensure main.go is built from the repository root. In other words, make sure PKG_BUILD_DIR actually contains the repository structure (including the go.mod).

--------------------------------------------------------------------------------
3. Double-Check File Locations
--------------------------------------------------------------------------------
Make sure that:
• Your main.go file is at the top of PKG_BUILD_DIR (or you adjust go build path accordingly).
• If go.mod is part of the repo, it is also at the same level, or you cd into the correct folder for the build.

--------------------------------------------------------------------------------
4. Keep Both MIPS And ARM64 Support
--------------------------------------------------------------------------------
These Prepare steps do not affect the multi-architecture support in golang.mk. You can still compile for both routers as before. Just ensure that each architecture either sees a valid go.mod or has the Build/Prepare logic to create one.

Putting it all together:
• Either restore the module-initializing Build/Prepare snippet if your repo doesn’t contain a go.mod.
• Or place your code such that go.mod is recognized at PKG_BUILD_DIR so the “go build” command doesn’t complain about “go.mod file not found.”

With these changes, you can keep the new multi-architecture logic in golang.mk and still compile successfully for both GL-AR300M and GL-MT3000.
Author Public Key
npub1ltng26f5q0uyycs05w8cnchals0vpw2uln925xvmerl6eded96zqcrt4hw