-
Notifications
You must be signed in to change notification settings - Fork 12
init: add go mod #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Thank you for your patch. Sorry, I did not have time to evaluate this until today.
I had a look at what other external plugins do, and I see more complete `go.mod` files in other plugins, such as <https://github.com/tmeckel/coredns-finalizer/blob/master/go.mod>. What do you think about adding something like that? Are there any downsides to that?
I'd also like to confirm the impact of adding this file on the development experience.
…On October 23, 2025 10:35:38 AM GMT+09:00, Adrian Salamon ***@***.***> wrote:
Add go module file. This is needed to make Nix builds work, since it assumes to compile with go 1.16 otherwise, which obviously fails.
Ref of how to use with Nix:
```nix
services.coredns = {
enable = true;
package = pkgs.coredns.override {
externalPlugins = lib.singleton {
name = "blocker";
repo = "github.com/icyflame/blocker";
version = "some_version";
};
vendorHash = lib.fakeHash; # replace with real hash after failing to build once
};
};
You can view, comment on, or merge this pull request online at:
#6
-- Commit Summary --
* init: add go mod
-- File Changes --
A go.mod (3)
-- Patch Links --
https://github.com/icyflame/blocker/pull/6.patch
https://github.com/icyflame/blocker/pull/6.diff
--
Reply to this email directly or view it on GitHub:
#6
You are receiving this because you are subscribed to this thread.
Message ID: ***@***.***>
--
Siddharth Kannan
|
|
I think adding dependencies would actually be worse in terms of bundling like above with Nix, since this would necessitate you versioning this together with coredns releases. For example, adding a require (
github.com/coredns/coredns v1.13.1
)Could make this be incompatible (not build) with other versions of coredns. I can't speak for compiling coredns manually like in your readme instructions, but I assume there would be problems there also. It's a little sad that go has no good way of specifying dependencies except for exact versions. |
|
Ah, I see, thanks for explaining. Yes, tying the plugin to a specific CoreDNS version is unnecessary and complicates the life of users. I will take a look at your PR as-is then.
|
|
I have been testing this locally. I am unable to build CoreDNS from source with a go.mod file inside the plugin/blocker directory. This is the error that I am seeing: $ make
go generate coredns.go
go get
go: github.com/coredns/coredns imports
github.com/coredns/coredns/core/plugin imports
github.com/coredns/coredns/plugin/blocker: cannot find module providing package github.com/coredns/coredns/plugin/blocker
go: module github.com/Azure/go-autorest/autorest is deprecated: use github.com/Azure/azure-sdk-for-go/sdk/azcore instead.
go: module github.com/Azure/go-autorest/autorest/azure/auth is deprecated: use github.com/Azure/azure-sdk-for-go/sdk/azidentity instead.
make: *** [Makefile:27: core/plugin/zplugin.go] Error 1Did you run into this? This is a longer example. The $ g log --oneline | head -1
1db4568df Bump version to 1.13.1 (#7599)
$ make
CGO_ENABLED=0 go build -v -ldflags="-s -w -X github.com/coredns/coredns/coremain.GitCommit=1db4568df-dirty" -o coredns
core/plugin/zplugin.go:14:2: no required module provides package github.com/coredns/coredns/plugin/blocker; to add it:
go get github.com/coredns/coredns/plugin/blocker
make: *** [Makefile:20: coredns] Error 1
$ cat plugin/blocker/go.mod
module github.com/icyflame/blocker
go 1.23.0
$ mv plugin/blocker/go.mod plugin/blocker/go.mod.1
$ make
CGO_ENABLED=0 go build -v -ldflags="-s -w -X github.com/coredns/coredns/coremain.GitCommit=1db4568df-dirty" -o coredns
|
|
Sorry for not getting back to you. I am able to compile this manually using the same steps as outlined in the official docs. $ git clone git@github.com:coredns/coredns.git
$ cd coredns
# change plugins.cfg
$ cat plugins.cfg
...
blocker:github.com/adriansalamon/blocker
forward:forward
...
$ go get github.com/adriansalamon/blocker@mine
$ go generate
$ make
$ ./coredns -plugins | grep blocker
blockerobviously, we can replace the URL to go test -v -count=1 github.com/adriansalamon/blocker
=== RUN TestIsDomainBlocked_ABP
=== RUN TestIsDomainBlocked_ABP/base_case
=== PAUSE TestIsDomainBlocked_ABP/base_case
=== CONT TestIsDomainBlocked_ABP/base_case
--- PASS: TestIsDomainBlocked_ABP (0.00s)
--- PASS: TestIsDomainBlocked_ABP/base_case (0.00s)
=== RUN TestIsDomainBlocked
=== RUN TestIsDomainBlocked/base_case
=== PAUSE TestIsDomainBlocked/base_case
=== CONT TestIsDomainBlocked/base_case
--- PASS: TestIsDomainBlocked (0.00s)
--- PASS: TestIsDomainBlocked/base_case (0.00s)
=== RUN TestConcurrentBlocklistAccess_PoC
--- PASS: TestConcurrentBlocklistAccess_PoC (0.09s)
PASS
ok github.com/adriansalamon/blocker 0.366sIf you want do develop against a local directory. You can simply add: |
Add go module file. This is needed to make Nix builds work, since it assumes to compile with go 1.16 otherwise, which obviously fails.
Ref of how to use with Nix: