diff options
author | Sean E. Russell <ser@ser1.net> | 2020-07-01 15:57:50 -0500 |
---|---|---|
committer | Sean E. Russell <ser@ser1.net> | 2020-07-01 15:57:50 -0500 |
commit | fc7e19d991bfdcbec11f2ccfd595379e939d7064 (patch) | |
tree | 9b082a8a950d9b72f112d04f8770b3a03232872d | |
parent | 9b176e678e8535bc72bede4f4b95318ce207644a (diff) |
Closes #140 -- include instructions in the README for properly setting the version.
-rw-r--r-- | README.md | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -62,9 +62,18 @@ gotop should build with most versions of Go. If you have a version other than 1 git clone https://github.com/xxxserxxx/gotop.git cd gotop sed -i '/^go/d' go.mod # Do this if you have go != 1.14 -go build -o gotop ./cmd/gotop +VERS="$(git tag -l --sort=-v:refname | sed 's/v\([^-].*\)/\1/g' | head -1 | tr -d '-' ).$(git describe --long --tags | sed 's/\([^-].*\)-\([0-9]*\)-\(g.*\)/r\2.\3/g' | tr -d '-')" +DAT=$(date +%Y%m%dT%H%M%S) +go build -o gotop \ + -ldflags "-X main.Version=v${VERS} -X main.BuildDate=${DAT}" \ + ./cmd/gotop ``` + go build \ + -gcflags "all=-trimpath=${PWD}" \ + -asmflags "all=-trimpath=${PWD}" \ + -ldflags "-X main.Version=v${VERSION} -X main.BuildDate=${BUILDDATE} -extldflags ${LDFLAGS}" \ + ./cmd/gotop Move `gotop` to somewhere in your `$PATH`. If Go is not installed or is the wrong version, and you don't have root access or don't want to upgrade Go, a script is provided to download Go and the gotop sources, compile gotop, and then clean up. See `scripts/install_without_root.sh`. |