Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R4R: Fix incorrect $GOBIN in Install Go. #4113

Merged
merged 2 commits into from
Apr 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pending/bugfixes/gaia/4113-Fix-incorrect-G
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4113 Fix incorrect `$GOBIN` in `Install Go`
4 changes: 2 additions & 2 deletions docs/cosmos-hub/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Install `go` by following the [official docs](https://golang.org/doc/install). R
```bash
mkdir -p $HOME/go/bin
echo "export GOPATH=$HOME/go" >> ~/.bash_profile
echo "export GOBIN=$GOPATH/bin" >> ~/.bash_profile
echo "export PATH=$PATH:$GOBIN" >> ~/.bash_profile
echo "export GOBIN=\$GOPATH/bin" >> ~/.bash_profile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need \ prefixes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In bash shell, variable in "" would be extended. The first version of cosmos docs was:

echo "export GOPATH=$HOME/go" >> ~/.bash_profile
source ~/.bash_profile
echo "export GOBIN=$GOPATH/bin" >> ~/.bash_profile
source ~/.bash_profile
echo "export PATH=$PATH:$GOBIN" >> ~/.bash_profile
source ~/.bash_profile

After source ~/.bash_profile, variable which was export just now was extended in current shell. So echo "export GOBIN=$GOPATH/bin" >> ~/.bash_profile was extended to echo "export GOBIN=/home/alice/go/bin" >> ~/.bash_profile. Otherwise it would be extended to echo "export GOBIN=/bin" >> ~/.bash_profile.

After executing all steps in first version, we got ~/.bash_profile :

......
export GOPATH=/home/alice/go
export GOBIN=/home/alice/go/bin
export PATH=/usr/bin/:usr/local/bin:......:/home/alice/go/bin

After executing all steps in current version, we got ~/.bash_profile :

......
export GOPATH=/home/alice/go
export GOBIN=/bin
export PATH=/usr/bin/:usr/local/bin:......:/bin

After executing all steps in PR version, we got ~/.bash_profile :

......
export GOPATH=/home/alice/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN

We also can modify as following because variables in '' would not be extended.

mkdir -p $HOME/go/bin
echo 'export GOPATH=$HOME/go' >> ~/.bash_profile
echo 'export GOBIN=$GOPATH/bin' >> ~/.bash_profile
echo 'export PATH=$PATH:$GOBIN' >> ~/.bash_profile
source ~/.bash_profile

Choosing prefix \ for keeping pace with other docs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In all honestly, I prefer the single-quote syntax

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like single-quote too. @alessio

echo "export PATH=\$PATH:\$GOBIN" >> ~/.bash_profile
source ~/.bash_profile
```

Expand Down