【发布时间】:2021-01-07 03:24:27
【问题描述】:
我在 Windows 10 中使用go1.14.1 和go-swagger 版本dev。我安装了go-swagger 和Installing from source。
【问题讨论】:
标签: go go-swagger
我在 Windows 10 中使用go1.14.1 和go-swagger 版本dev。我安装了go-swagger 和Installing from source。
【问题讨论】:
标签: go go-swagger
安装过程与 master (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。版本信息只是从 git 存储库作为commands 包中的变量内容传递下来的装饰性信息,您可以在他们的 CircleCI 配置文件here 中看到作者是如何做到的。最终,您还可以添加其他标志来获得静态构建(但官方从源代码安装说明中没有这样做)。
完成后,您应该在 $GOPATH/bin 中安装 go-swagger v0.25.0,通过以下方式验证:
$ swagger version
version: v0.25.0
commit: f032690aab0634d97e2861a708d8fd9365ba77d2
【讨论】: