I can’t get the version number after compiling, and prompt unknown, how can I solve it?
$ git clone https://github.com/caddyserver/caddy.git
$ cd caddy/caddy/
$ go build
root@ip:~/caddy/caddy# ./caddy -version
unknown
I can’t get the version number after compiling, and prompt unknown, how can I solve it?
$ git clone https://github.com/caddyserver/caddy.git
$ cd caddy/caddy/
$ go build
root@ip:~/caddy/caddy# ./caddy -version
unknown
Hi Adrian, please try following the instructions in the README under the heading"To build Caddy with plugins (and with version information)":
There is no need to modify the Caddy code to build it with plugins. We will create a simple Go module with our own
main()
that you can use to make custom Caddy builds.
- Set the transitional environment variable for Go modules:
export GO111MODULE=on
- Create a new folder anywhere and within create a Go file (extension
.go
) with the contents below, adjusting to import the plugins you want to include:
(snippet omitted here)go mod init caddy
- Run
go get github.com/caddyserver/caddy
go install
will then create your binary at$GOPATH/bin
, orgo build
will put it in the current directory.
That will embed version information.
I really like how the install works with Go modules – really nice!
I started an Ansible plugin that automates this:
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.