I’m confusing myself when attempting to build caddy from source with plugins for specific testing and following the directions from the Caddy readme.md. As a non go programmer I’m going in circles here so I’m going to stop and ask. The readme.md for caddy states the following:
With version information and/or plugins
Using our builder tool, xcaddy
… >>> YEP got xcaddy installed on system, OK I’m ready for next step and… ok this looks too simple?
$ xcaddy build
This part fails for me, I’m assuming I can NOT use go 1.18 here and should fall back to go 1.16 to get past this error (I’m wanting to confirm this)?
2022/03/16 21:42:28 [INFO] exec (timeout=0s): /usr/bin/go build -o /home/agrajag/caddy -ldflags -w -s -trimpath
# github.com/lucas-clemente/quic-go/internal/qtls
/home/agrajag/go/pkg/mod/github.com/lucas-clemente/quic-go@v0.23.0/internal/qtls/go118.go:5:13: cannot use "quic-go doesn't build on Go 1.18 yet." (untyped string constant) as int value in variable declaration
2022/03/16 21:44:38 [INFO] Cleaning up temporary folder: /tmp/buildenv_2022-03-16-2141.215925827
2022/03/16 21:44:38 [FATAL] exit status 2
…the following steps are automated: >>> This is where I get completely lost as I’m trying to add plugins and the steps fall apart logically for me?
- Create a new folder:
mkdir caddy
- Change into it:
cd caddy
<< Ok I understand these first two steps… - Copy Caddy’s main.go into the empty folder. Add imports for any custom plugins you want to add. <<< Ok on grabbing the file, but I’m starting to get lost here
- Initialize a Go module:
go mod init caddy
<<< not sure what this is doing, but "OK" - (Optional) Pin Caddy version:
go get github.com/caddyserver/caddy/v2@version
replacingversion
with a git tag, commit, or branch name. <<< so I think this would be something like:
go get github.com/caddyserver/caddy/v2@v2.5.0-beta.1
- (Optional) Add plugins by adding their import:
_ "import/path/here"
<<< this is not clear as to what to provide for this step… Do I use a agit clone
of the plugin and provide the path of it, replacing the whole import/path/here to provide it? Am I editing something to add the import: assertion that seems to be indicated, for example:
import:_/home/agrajag/someplugin-git-clone-path
OR is it
import:_ "/home/agrajag/someplugin-git-clone-path"
or some other variant not obvious to the non go enthusiast?
- Compile:
go build
With this last step, again I’m assuming this will fail as long as I attempt to use 1.18…
Thanks in advance for any clarifying pointers (or longer example pointer to what I could not locate…)