1 回答

TA貢獻1856條經(jīng)驗 獲得超11個贊
安裝過程與主 () 版本相同,只是您需要再執(zhí)行一個附加步驟,即在將存儲庫克隆到臨時目錄后簽出標記:devv0.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
注意:如果您這樣做,從技術(shù)上講,它仍將安裝 v0.25.0,但子命令會將其報告為 。版本信息只是從git存儲庫作為包中的變量內(nèi)容傳遞出來的裝飾性內(nèi)容,您可以在此處的CircleCI配置文件中看到作者如何執(zhí)行此操作。最終,您還可以添加其他標志來獲得靜態(tài)構(gòu)建(但它們在官方的從源代碼安裝說明中不會這樣做)。go install ./cmd/swaggerswagger versiondevcommands
完成后,您應(yīng)該在 中安裝 go-swagger v0.25.0,驗證:$GOPATH/bin
$ swagger version
version: v0.25.0
commit: f032690aab0634d97e2861a708d8fd9365ba77d2
- 1 回答
- 0 關(guān)注
- 201 瀏覽
添加回答
舉報