gpt4 book ai didi

go - 在Windows中将gossagger替换为另一个版本

转载 作者:行者123 更新时间:2023-12-03 10:09:15 25 4
gpt4 key购买 nike

我在Windows 10中使用go1.14.1go-swagger版本dev。我将go-swaggerInstalling from source安装在一起。
我想改用go-swagger版本 0.25 。用 dev 替换0.25的干净方法是什么?

最佳答案

安装过程与主版本(dev)相同,只不过您需要执行另一步,即在将存储库克隆到临时目录后 checkout 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

关于go - 在Windows中将gossagger替换为另一个版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65606224/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com