I followed the instructions from the README today to build Caddy from source with plugins, but when I ran go build, Go pulled the source code from the latest release tag (v0.11.5) instead of the most recent pre-release tag (v1.0.0-beta1).
Is it possible to specify either a pre-release tag or a specific commit when building Caddy from source with plugins?
@mholt Your input would be appreciated.
Yes, see the README for instructions on how to build from source at a specific release, see also the Go module documentation and the discussion in https://github.com/mholt/caddy/issues/2560.
@mholt Thanks, I figured it out now.
@whalehub What was your solution?
@mholt When I ran build.go, Go automatically populated the go.mod file with the required dependencies. Among them was github.com/mholt/caddy with the version tag v0.11.5. After consulting Go's documentation, I found out that you can specify a prerelease tag or a commit for a required dependency by replacing the versioned tag with the respective prerelease tag or the commit's hash (e.g. 917d9bc9daf9740c83b2ee686f21f4c54cdf21ad). Go will automatically convert the latter into a so-called pseudo-version (e.g. v1.0.0-beta1.0.20190420181127-917d9bc9daf9) when you run go build again.
I was able to build Caddy from the latest commit with plugins this way without a problem.
root@debian:~/.caddy/build# ./caddy -version
Caddy v1.0.0-beta1.0.20190420181127-917d9bc9daf9 (h1:Qy+MKd5e5M3p2x21Bm/wxzpTR7T4tE/xq/n9AV3nM88=)
Thanks. But, we just removed build.go... it is no longer needed.
@mholt That was a typo. I meant to say "When I ran go build [...]".
Are the instructions in our readme wrong then? We specifically mention a beta version because Go modules ignores prereleases otherwise.
@mholt As far as I can tell, the instructions for building Caddy without plugins are correct. It's the instructions for building it with plugins that require an overhaul. If you want, I can type something up to fix them.
What needs to be changed? They worked for me last night.
What needs to be changed? They worked for me last night.
Run go get github.com/mholt/[email protected] before go build. This will not be necessary after the release of the v1.0.0 version tag
Edit:
This should be the content of go.mod:
module caddy
go 1.12
require github.com/mholt/caddy v1.0.0-beta2
Furthermore, I propose another change.
go mod init mycaddy(the name doesn't really matter).
This is not really true, the module name equals the name of the binary i.e if it is called mycaddy the binary will be called mycaddy
馃 Huh, I thought the name of the binary was based on the folder name.
But yes, a lot of pain will go away after a stable release. It's a chicken-and-egg problem. At this point I'll be tagging 1.0 just hoping it works. 馃槵
馃 Huh, I thought the name of the binary was based on the folder name.
Not for me... Can anyone confirm this?