From d81fe27952e373783eee06e29537351edd281ef3 Mon Sep 17 00:00:00 2001 From: Paul Jolly Date: Thu, 25 Oct 2018 14:08:59 +0100 Subject: [PATCH] README: fix installation instructions Encouraging people to clone the repo means they won't get a sensible tagged version. Instead, use the "hack" of creating a temporary module, adding github.com/myitcv/gobin as a dependency via go get, then using go install. The logic in go get will use the latest tagged version. Resulting README can be seen at https://github.com/myitcv/gobin/blob/fix_installation_instructions/README.md Also bump to v1.0.0 of go-internal and myitcv.io@latest in the process. Use v1.0.0-alpha.2 of gohack for examples. --- .installation.sh | 27 ----------- .examples.sh => .readme.sh | 23 +++++----- README.md | 91 ++++++++++++++++---------------------- go.mod | 6 +-- go.sum | 8 ++-- 5 files changed, 56 insertions(+), 99 deletions(-) delete mode 100644 .installation.sh rename .examples.sh => .readme.sh (67%) diff --git a/.installation.sh b/.installation.sh deleted file mode 100644 index ae21a21..0000000 --- a/.installation.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -# **START** - -echo "machine github.com login $GITHUB_USERNAME password $GITHUB_PAT" >> $HOME/.netrc -echo "" >> $HOME/.netrc -echo "machine api.github.com login $GITHUB_USERNAME password $GITHUB_PAT" >> $HOME/.netrc -git config --global user.email "$GITHUB_USERNAME@example.com" -git config --global user.name "$GITHUB_USERNAME" -git config --global advice.detachedHead false -git config --global push.default current - -# block: clone -export GO111MODULE=on -git clone https://github.com/myitcv/gobin /tmp/gobin -cd /tmp/gobin - -# block: install -go install - -# block: fix path -export PATH=$(go env GOPATH)/bin:$PATH -which gobin - -# block: use -gobin -r github.com/rogpeppe/gohack@master -help -assert "$? -eq 2" $LINENO diff --git a/.examples.sh b/.readme.sh similarity index 67% rename from .examples.sh rename to .readme.sh index 97fe82d..898d5b6 100644 --- a/.examples.sh +++ b/.readme.sh @@ -10,13 +10,16 @@ git config --global user.name "$GITHUB_USERNAME" git config --global advice.detachedHead false git config --global push.default current -unset GOPATH - -# these steps are effectively copied from .installation.sh +# block: clone export GO111MODULE=on -git clone https://github.com/myitcv/gobin /tmp/gobin -cd /tmp/gobin -go install +cd $(mktemp -d) +go mod init mod +go get -m github.com/myitcv/gobin + +# block: install +go install github.com/myitcv/gobin + +# block: fix path export PATH=$(go env GOPATH)/bin:$PATH which gobin @@ -26,13 +29,13 @@ gobin github.com/rogpeppe/gohack # block: gohack latest gobin github.com/rogpeppe/gohack@latest -# block: gohack v1.0.0-alpha.1 -gobin github.com/rogpeppe/gohack@v1.0.0-alpha.1 +# block: gohack v1.0.0-alpha.2 +gobin github.com/rogpeppe/gohack@v1.0.0-alpha.2 # block: gohack print -gobin -p github.com/rogpeppe/gohack@v1.0.0-alpha.1 +gobin -p github.com/rogpeppe/gohack@v1.0.0-alpha.2 # block: gohack run -gobin -r github.com/rogpeppe/gohack@v1.0.0-alpha.1 -help +gobin -r github.com/rogpeppe/gohack@v1.0.0-alpha.2 -help assert "$? -eq 2" $LINENO diff --git a/README.md b/README.md index df47ee2..1fbd49a 100644 --- a/README.md +++ b/README.md @@ -8,14 +8,15 @@ The gobin command installs/runs main packages. -### Installation - +### Examples -Clone the `gobin` repo: +Globally install `gohack`: ``` -$ export GO111MODULE=on -$ git clone https://github.com/myitcv/gobin /tmp/gobin -Cloning into '/tmp/gobin'... -$ cd /tmp/gobin +{{PrintBlock "gohack" -}} ``` -Install: +Install a specific version of `gohack`: ``` -$ go install -... +{{PrintBlock "gohack v1.0.0-alpha.2" -}} ``` -Update your `PATH` and verify we can find `gobin` in our new `PATH`: +Print the `gobin` cache location of a specific `gohack` version: ``` -$ export PATH=$(go env GOPATH)/bin:$PATH -$ which gobin -/home/gopher/gopath/bin/gobin +{{PrintBlock "gohack print" -}} ``` -Use `gobin` as a "test": +Run a specific `gohack` version: ``` -$ gobin -r github.com/rogpeppe/gohack@master -help -The gohack command checks out Go module dependencies -into a directory where they can be edited, and adjusts -the go.mod file appropriately. -... +{{PrintBlock "gohack run" -}} ``` - - -### Examples - - -``` -{{PrintBlock "gohack" -}} -``` +### Installation -Install a specific version of `gohack`: +Use a temporary module to get the latest version of `github.com/myitcv/gobin`: ``` -{{PrintBlock "gohack v1.0.0-alpha.1" -}} +$ export GO111MODULE=on +$ cd $(mktemp -d) +$ go mod init mod +go: creating new go.mod: module mod +$ go get -m github.com/myitcv/gobin +... ``` -Print the `gobin` cache location of a specific `gohack` version: +Install: ``` -{{PrintBlock "gohack print" -}} +$ go install github.com/myitcv/gobin +... ``` -Run a specific `gohack` version: +Update your `PATH` and verify we can find `gobin` in our new `PATH`: ``` -{{PrintBlock "gohack run" -}} +$ export PATH=$(go env GOPATH)/bin:$PATH +$ which gobin +/home/gopher/gopath/bin/gobin ``` - ---> +### Examples Globally install `gohack`: ``` $ gobin github.com/rogpeppe/gohack -Installed github.com/rogpeppe/gohack@v0.0.1 to /home/gopher/go/bin/gohack +Installed github.com/rogpeppe/gohack@v0.0.1 to /home/gopher/gopath/bin/gohack ``` Install a specific version of `gohack`: ``` -$ gobin github.com/rogpeppe/gohack@v1.0.0-alpha.1 -Installed github.com/rogpeppe/gohack@v1.0.0-alpha.1 to /home/gopher/go/bin/gohack +$ gobin github.com/rogpeppe/gohack@v1.0.0-alpha.2 +Installed github.com/rogpeppe/gohack@v1.0.0-alpha.2 to /home/gopher/gopath/bin/gohack ``` Print the `gobin` cache location of a specific `gohack` version: ``` -$ gobin -p github.com/rogpeppe/gohack@v1.0.0-alpha.1 -/home/gopher/.cache/gobin/github.com/rogpeppe/gohack/@v/v1.0.0-alpha.1/github.com/rogpeppe/gohack/gohack +$ gobin -p github.com/rogpeppe/gohack@v1.0.0-alpha.2 +/home/gopher/.cache/gobin/github.com/rogpeppe/gohack/@v/v1.0.0-alpha.2/github.com/rogpeppe/gohack/gohack ``` Run a specific `gohack` version: ``` -$ gobin -r github.com/rogpeppe/gohack@v1.0.0-alpha.1 -help +$ gobin -r github.com/rogpeppe/gohack@v1.0.0-alpha.2 -help The gohack command checks out Go module dependencies into a directory where they can be edited, and adjusts the go.mod file appropriately. @@ -147,7 +131,6 @@ The commands are: Use "gohack help " for more information about a command. ``` - ### Usage diff --git a/go.mod b/go.mod index 1a3f619..aeda045 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module github.com/myitcv/gobin require ( - github.com/rogpeppe/go-internal v1.0.0-alpha - myitcv.io v0.0.0-20181024001312-926e6775fd21 + github.com/rogpeppe/go-internal v1.0.0 + myitcv.io v0.0.0-20181024170518-69843ea77cfd ) - -replace github.com/rogpeppe/go-internal => github.com/myitcv/go-internal v1.0.0-alpha.0.20181023085657-b3919076a82e diff --git a/go.sum b/go.sum index db64679..f55f926 100644 --- a/go.sum +++ b/go.sum @@ -15,10 +15,10 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/myitcv/go-internal v1.0.0-alpha.0.20181023085657-b3919076a82e h1:DdePa8RW95raZ79rL4AU915Lpdyz8FmStI+ng+Hf7Ls= -github.com/myitcv/go-internal v1.0.0-alpha.0.20181023085657-b3919076a82e/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/rogpeppe/go-internal v1.0.0 h1:o4VLZ5jqHE+HahLT6drNtSGTrrUA3wPBmtpgqtdbClo= +github.com/rogpeppe/go-internal v1.0.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/russross/blackfriday v1.5.1/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -47,5 +47,5 @@ honnef.co/go/js/util v0.0.0-20150216223935-96b8dd9d1621/go.mod h1:WrAIh8rWfzvMdL honnef.co/go/js/xhr v0.0.0-20150307031022-00e3346113ae/go.mod h1:QwoYXdHZpuR080H32s5jqyk7zh/k/U9bDFg2g8OMmOM= mvdan.cc/sh v2.5.0+incompatible h1:JNM6l18iQFGZl0dK2n/7Z85sNaFq9zSl3qooNNyl+qA= mvdan.cc/sh v2.5.0+incompatible/go.mod h1:IeeQbZq+x2SUGBensq/jge5lLQbS3XT2ktyp3wrt4x8= -myitcv.io v0.0.0-20181024001312-926e6775fd21 h1:OHvJTKuOUN+9gMs9zy8NJL6d+Yob+yiKOX14mJO/ifs= -myitcv.io v0.0.0-20181024001312-926e6775fd21/go.mod h1:0yVf2bHw6qSFxyjj1hJ+yA68GjlMIr6FZcQgBG9Cqq0= +myitcv.io v0.0.0-20181024170518-69843ea77cfd h1:wJZBNGj4rAqFC7Uvj8qeJ8rBKfhbvj47g/0wkN5R0Ew= +myitcv.io v0.0.0-20181024170518-69843ea77cfd/go.mod h1:0yVf2bHw6qSFxyjj1hJ+yA68GjlMIr6FZcQgBG9Cqq0=