Skip to content
This repository was archived by the owner on Jul 1, 2022. It is now read-only.
This repository was archived by the owner on Jul 1, 2022. It is now read-only.

"make daemon" doesn't build on Go 1.16 due to changes to its module system #29

Description

@joeshaw

Describe the bug

If you have Go 1.16 installed, the Go portions of the project no longer build. For example, make daemon. This is because Go 1.16 switched to requiring Go modules by default.

pronto /tmp/c-sdk (main)$ make daemon
/Applications/Xcode.app/Contents/Developer/usr/bin/make USE_SYSTEM_CERTS=1 -C vendor/newrelic daemon
go install -ldflags '-X newrelic/version.Number=1.3.0.0 -X newrelic/version.Commit=fe05ae84e4fe -X newrelic/secrets.NewrelicCollectorHost= -X newrelic/secrets.NewrelicLicenseKey= -X newrelic/secrets.NewrelicCollectorKeys=' -tags='use_system_certs' ./...
go: cannot find main module, but found .git/config in /private/tmp/c-sdk
	to create a module there, run:
	cd ../.. && go mod init
make[1]: *** [daemon] Error 1
make: *** [newrelic-daemon] Error 2

pronto /tmp/c-sdk (main)$ go version
go version go1.16.2 darwin/amd64

Your Environment

I'm running this on MacOS 11.3 (Big Sur) with Go 1.16.2, but this also happens on Linux.

Additional context

A summary of the modules changes is available on the Go blog: https://blog.golang.org/go116-module-changes

A temporary workaround is to set GO111MODULES=auto. However, non-modules (aka GOPATH-mode) is scheduled to be dropped in Go 1.17.

The build system of Go code in this repository is very unusual, and doesn't follow best practices. For example, overriding GOPATH and not namespacing package import paths. One of the reason why projects did this, however, is because GOPATH was global on a user's machine. The Go module system makes this a lot cleaner and allows you to specify your dependencies more exactly.

My suggestion is to bump the minimum required Go version to 1.13 (the first one where modules were enabled and auto-detected) and switch to using Go modules. Go 1.13 was released in September 2019.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions