mirror of
https://github.com/navidrome/navidrome.git
synced 2025-03-31 11:07:36 +03:00
build(netgo): make sure the project is always compiled with netgo
build tag (#3428)
* build(netgo): make sure the project is always compiled with `netgo` build tag * docs(netgo): better comments
This commit is contained in:
parent
15b2dc6b48
commit
69e2a6d620
6 changed files with 30 additions and 3 deletions
2
.github/workflows/pipeline.yml
vendored
2
.github/workflows/pipeline.yml
vendored
|
@ -102,7 +102,7 @@ jobs:
|
|||
- name: Test
|
||||
run: |
|
||||
pkg-config --define-prefix --cflags --libs taglib # for debugging
|
||||
go test -shuffle=on -race -cover ./... -v
|
||||
go test -shuffle=on -tags netgo -race -cover ./... -v
|
||||
|
||||
js:
|
||||
name: Test JS code
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
run:
|
||||
build-tags:
|
||||
- netgo
|
||||
|
||||
linters:
|
||||
enable:
|
||||
- asasalint
|
||||
|
|
4
Makefile
4
Makefile
|
@ -33,11 +33,11 @@ server: check_go_env buildjs ##@Development Start the backend in development mod
|
|||
.PHONY: server
|
||||
|
||||
watch: ##@Development Start Go tests in watch mode (re-run when code changes)
|
||||
go run github.com/onsi/ginkgo/v2/ginkgo@latest watch -notify ./...
|
||||
go run github.com/onsi/ginkgo/v2/ginkgo@latest watch -tags netgo -notify ./...
|
||||
.PHONY: watch
|
||||
|
||||
test: ##@Development Run Go tests
|
||||
go test -race -shuffle=on ./...
|
||||
go test -tags netgo -race -shuffle=on ./...
|
||||
.PHONY: test
|
||||
|
||||
testall: test ##@Development Run Go and JS tests
|
||||
|
|
4
conf/buildtags/buildtags.go
Normal file
4
conf/buildtags/buildtags.go
Normal file
|
@ -0,0 +1,4 @@
|
|||
package buildtags
|
||||
|
||||
// This file is left intentionally empty. It is used to make sure the package is not empty, in the case all
|
||||
// required build tags are disabled.
|
11
conf/buildtags/netgo.go
Normal file
11
conf/buildtags/netgo.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
//go:build netgo
|
||||
|
||||
package buildtags
|
||||
|
||||
// NOTICE: This file was created to force the inclusion of the `netgo` tag when compiling the project.
|
||||
// If the tag is not included, the compilation will fail because this variable won't be defined, and the `main.go`
|
||||
// file requires it.
|
||||
|
||||
// Why this tag is required? See https://github.com/navidrome/navidrome/issues/700
|
||||
|
||||
var NETGO = true
|
8
main.go
8
main.go
|
@ -4,8 +4,16 @@ import (
|
|||
_ "net/http/pprof" //nolint:gosec
|
||||
|
||||
"github.com/navidrome/navidrome/cmd"
|
||||
"github.com/navidrome/navidrome/conf/buildtags"
|
||||
)
|
||||
|
||||
//goland:noinspection GoBoolExpressions
|
||||
func main() {
|
||||
// This import is used to force the inclusion of the `netgo` tag when compiling the project.
|
||||
// If you get compilation errors like "undefined: buildtags.NETGO", this means you forgot to specify
|
||||
// the `netgo` build tag when compiling the project.
|
||||
// To avoid these kind of errors, you should use `make build` to compile the project.
|
||||
_ = buildtags.NETGO
|
||||
|
||||
cmd.Execute()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue