发布于 2021-01-07 03:50:26
安装过程与主(dev)版本相同,但您还需要执行另外一个步骤,即在将repo克隆到临时目录后签出标记v0.25.0:
dir=$(mktemp -d)
git clone https://github.com/go-swagger/go-swagger "$dir"
cd "$dir"
# Checkout version v0.25.0
git checkout v0.25.0
# Continue with installation, instead of
# go install ./cmd/swagger
# use this which just adds version information (current tag) and commit id to binary
go install -ldflags "-X github.com/go-swagger/go-swagger/cmd/swagger/commands.Version=$(git describe --tags) -X github.com/go-swagger/go-swagger/cmd/swagger/commands.Commit=$(git rev-parse HEAD)" ./cmd/swagger注意:如果您只安装go install ./cmd/swagger,技术上它仍然会安装v0.25.0,但是swagger version子命令会将其报告为dev。版本信息只是作为commands包中变量的内容从git存储库向下传递的一种外观,您可以在CircleCI配置文件这里中看到作者是如何做到这一点的。最终,您还可以添加其他标志以获得静态构建(但它们不会在正式安装时使用源代码说明)。
一旦完成,您应该已经在您的$GOPATH/bin中安装了go-swagger v0.25.0,请用以下方法验证:
$ swagger version
version: v0.25.0
commit: f032690aab0634d97e2861a708d8fd9365ba77d2https://stackoverflow.com/questions/65606224
复制相似问题