How to do “go get” on a specific tag of a github repository

前端 未结 6 1557
孤街浪徒
孤街浪徒 2020-12-13 03:35

I am trying to compile the InfluxDB database (version v0.8.8) using go get github.com/influxdb/influxdb

But this pulls the master branch, and I need the

6条回答
  •  一生所求
    2020-12-13 04:05

    go mod is available now.

    For those who need to build a binary of a specific tag, here is my way:

    mkdir temp
    cd temp
    go mod init .
    go get -d -v github.com/nsqio/nsq@v1.1.0
    mkdir bin
    go build -o bin/nsqd.exe github.com/nsqio/nsq/apps/nsqd
    

    Explanation:

    • The above code pulls NSQ v1.1.0 and build nsqd.
    • go mod init . creates a go.mod file in the current directory, which enables using go get with revision/tags. (see this link)
    • -d means "download only", if you want a direct installation, omit this flag and the build commands below this line.
    • -v means "be verbose".
    • The above code is for Windows. If you use Linux, replace bin/nsqd.exe with bin/nsqd.

    The module downloaded is stored in %GOPATH%\pkg\mod. If you don't want to pollute your GOPATH directory, make a new one and set your GOPATH to it.

提交回复
热议问题