According to this document I need to add -mod=vendor
to my build command to make use of my local vendor
folder:
By default, go commands like go build ignore the vendor directory when in module mode. The -mod=vendor flag (e.g., go build -mod=vendor) instructs the go commands to use the main module's top-level vendor directory to satisfy dependencies.
When I run this command:
go build -mod=vendor -a -ldflags "-s -w -X github.com/my-api/pkg/config.Version=169.3988801" -o bin/my-api
I get this error:
build flag -mod=vendor only valid when using modules
Locally the command works as expected, the error only occurs on the build server.