Missing go.mod in caddy submodule
This is a pretty minor issue so please feel free to close it if you don't think it's worth your time.
Context
The nix/nixpkgs build system provides an integration to build caddy with a list of extensions (using xcaddy or a process like xcaddy under the covers). This lets me write something like the following and get a reproducible build build of caddy with go-pmtiles in just a couple of lines:
# default.nix
{ caddy }:
caddy.withPlugins {
plugins = [
"github.com/protomaps/go-pmtiles/[email protected]"
];
hash = "sha256-QVyV1PPYqQQnS531BDzp8Equ0le1AzyOHbsCjeOVlew=";
}
Issue
As part of its checks, this integration looks at caddy build-info and checks that all of the requested plugins show up. Unfortunately this check currently isn't working for go-pmtiles because of a mismatch between the requested plugin and the output in build-info (example using xcaddy):
$ xcaddy build --with github.com/protomaps/go-pmtiles/[email protected]
$ ./caddy/caddy build-info | grep pmtiles
dep github.com/protomaps/go-pmtiles v1.28.0 h1:Q23U0DqfVE0PM2ZVcehgZ4yIjd73jcK5UMKcX6K5R3c=
(notice github.com/protomaps/go-pmtiles/caddy vs. github.com/protomaps/go-pmtiles).
I raised https://github.com/NixOS/nixpkgs/issues/430090 as a result to look into it.
Request
@stepbrobd has pointed out this is likely due to a missing go.{mod,sum} under the caddy directory. By way of comparison, building with github.com/darkweak/storages/badger/caddy does show up the full path in caddy build-info:
$ ./result/bin/caddy build-info | grep badger
dep github.com/darkweak/storages/badger v0.0.15
dep github.com/darkweak/storages/badger/caddy v0.0.15
dep github.com/dgraph-io/badger/v3 v3.2103.5
build -tags=nobadger,nomysql,nopgx
This is a link to badger's go.mod: https://github.com/darkweak/storages/blob/main/badger/caddy/go.mod
Would it be feasible to get a go.mod added to the directory so it acts like a proper module? I'm not hugely familiar with go tooling, so I don't know what the impact would be.
I attempted to add a go.mod in the caddy subdirectory like this:
go mod init github.com/protomaps/go-pmtiles/caddy
But then go mod tidy fails with this:
go: github.com/protomaps/go-pmtiles/caddy: ambiguous import: found package github.com/protomaps/go-pmtiles/caddy in multiple modules:
github.com/protomaps/go-pmtiles v1.28.0 (/Users/.../go/pkg/mod/github.com/protomaps/[email protected]/caddy)
github.com/protomaps/go-pmtiles/caddy (/Users/.../protomaps/go-pmtiles/caddy)
I'm not an expert on Caddy builds, go packaging or Nix so if you can design a working PR to have a go.mod in the caddy dir, that does not have other maintainability side effects (like affecting the root go.mod), I'm open to merging that.