sjmudd / ps-top

ps-top - a top-like program for MySQL
BSD 2-Clause "Simplified" License
205 stars 31 forks source link

Can't install on Ubuntu #8

Closed tdeo closed 6 years ago

tdeo commented 7 years ago

Hi @sjmudd,

I'm running into this issue while trying to install ps-top since a few weeks:

$ GOPATH=/home/ubuntu/gocode go get -u github.com/sjmudd/mysql_defaults_file
$ GOPATH=/home/ubuntu/gocode go get -u github.com/nsf/termbox-go
$ GOPATH=/home/ubuntu/gocode go get -u github.com/sjmudd/ps-top/cmd/ps-top
# github.com/go-sql-driver/mysql
gocode/src/github.com/go-sql-driver/mysql/utils.go:806:10: error: reference to undefined identifier ‘atomic.Value’
  value   atomic.Value
          ^
gocode/src/github.com/go-sql-driver/mysql/packets.go:1095:26: error: reference to undefined field or method ‘AppendFormat’
      b = v.In(mc.cfg.Loc).AppendFormat(b, timeFormat)
                          ^

Would you know how to solve this ? Thanks

sjmudd commented 7 years ago

This works for me (the build works), just done:

[user@myhost ~]$ mkdir -p src/ps-top/src/github.com/sjmudd
[user@myhost ~]$ cd src/ps-top/src/github.com/sjmudd
[user@myhost ~/src/ps-top/src/github.com/sjmudd]$ export GOPATH=~/src/ps-top
[user@myhost ~/src/ps-top/src/github.com/sjmudd]$ go get github.com/sjmudd/ps-top/cmd/ps-top
[user@myhost ~/src/ps-top/src/github.com/sjmudd]$ cd ps-top/cmd/ps-top
[user@myhost ~/src/ps-top/src/github.com/sjmudd/ps-top/cmd/ps-top]$ go build
[user@myhost ~/src/ps-top/src/github.com/sjmudd/ps-top/cmd/ps-top]$ ls
ps-top          ps-top.go
[user@myhost ~/src/ps-top/src/github.com/sjmudd/ps-top/cmd/ps-top]$ ./ps-top
2017/09/06 18:15:00 dial tcp 127.0.0.1:3306: getsockopt: connection refused
[user@myhost ~/src/ps-top/src/github.com/sjmudd/ps-top/cmd/ps-top]$

I don't have MySQL running now but I think you get the idea. Please try and see if it works for you.

Obviously you need to configure access credentials to the system you want to use. I usually use a MySQL defaults file to avoid explicitly passing passwords on the command line. YMMV.

sjmudd commented 7 years ago

Also notice that you do not need to explicitly pull in the dependencies as they included in the git tree and are handled under the vendor directory.

tdeo commented 7 years ago

Trying the same steps as you do, I'm getting the same problem:

$ go get github.com/sjmudd/ps-top/cmd/ps-top
# github.com/go-sql-driver/mysql
../gocode/src/github.com/go-sql-driver/mysql/utils.go:806: undefined: atomic.Value

I looked a bit online, and it seems it can be related to go version, which one are you running ? I have 1.2.1

sjmudd commented 7 years ago

Yes. Go 1.2 does not support the "vendor branching" which was introduced in 1.5. (See: https://blog.gopheracademy.com/advent-2015/vendor-folder/ for a reference.) This basically makes it possible to keep a copy of external dependencies and without that you'd need to pull in outside dependencies as you've done. However, you don't control this way exactly which version of the external git repos you are using and this is not tracked which is why the external vendor facility was added. If upstream change their code then code that depends on this may break. I think that's what you're suffering from.

My suggestion to you is to download the latest go (1.9 is the latest version atm) but anything newer than 1.6 should be good) and try again.

tdeo commented 6 years ago

Closing in housekeeping - thanks for your help