Can't figure out how to build termeter
Hi;
I've never used go before, but termeter looks good enough that I'm making the effort.
Getting it running was hard; I had assumptions that were not true. Here's how to get termeter running, for beginners:
echo 'export GOPATH=$HOME/gocode' >> ~/.bashrc
echo 'export GOBIN=$HOME/bin' >> ~/.bashrc
source ~/.bashrc
go get github.com/atsaki/termeter/cmd/termeter
cd $GOPATH/src/github.com/atsaki/termeter/cmd/termeter/
go build
./termeter --help
go install
$GOBIN/termeter --help
Here are the things I figured out:
- Using 'cd /tmp; git clone https://github.com/atsaki/termeter.git; cd termeter; go build' won't work; the files have to be in the right directory.
- The $GOPATH and $GOBIN environment variables have to exist.
- The 'go build' command must be run in $GOPATH/src/github.com/atsaki/termeter/cmd/termeter/ , not $GOPATH/src/github.com/atsaki/termeter
- If you do 'go build' in that directory, termeter will be created in that directory. If you do 'go install', termeter will be moved to $GOBIN/termeter. However, if you do 'go install -a github.com/atsaki/termeter/cmd/termeter' from your home directory, you'll get 'go install runtime: open /usr/lib/golang/pkg/linux_amd64/runtime.a: permission denied'
- If you're in the same directory as the README.md file, 'go build' won't create 'termeter' and won't print any error messages; you have to be do 'cd ./cmd/termeter; go build'.
Ok, thanks for writing this!
I followed the upper portion because... well, it said for beginners. That's me.
Trying to install on a pi zero w, and when I get to go build the response is
../../../../mattn/go-runewidth/runewidth.go:7:2: found packages uniseg (doc.go) and main (gen_breaktest.go) in /home/pi/gocode/src/github.com/rivo/uniseg
termeter --help returns -bash: termeter: command not found
Any advice would be appreciated.
The thing with bash is, if you type a command, bash will then look in each of the directories in your $PATH environment variable for a file with that name, and if it finds it (and the permissions say it's an executable program), then it'll try to load it and run it, which is what you want. To see what your $PATH is right now, try echo $PATH. To set it, try PATH=/bin:/usr/bin:/usr/local/bin. If you mess it up, just log out and back in.
If the command isn't in your path, bash isn't going to find it. If you add . to your path then bash will look in the current directory too, but some say that it is a security feature to not do that.
If you still want to run a program but it's not in your path, you can specify the directory (full path or relative path), and then it'll run: /home/mattn/something/something/termeter