bcicen / ctop

Top-like interface for container metrics
https://ctop.sh
MIT License
15.51k stars 525 forks source link

Can't `go get` with Go 1.11 #141

Closed mrichman closed 5 years ago

mrichman commented 6 years ago

I just installed Go 1.11:

$ go get github.com/bcicen/ctop
# github.com/bcicen/ctop/cwidgets/single
go/src/github.com/bcicen/ctop/cwidgets/single/cpu.go:23:11: cannot use tmpData (type []float64) as type map[string][]float64 in assignment
go/src/github.com/bcicen/ctop/cwidgets/single/cpu.go:26:11: cannot use cpu.hist.Data (type []float64) as type map[string][]float64 in assignment
go get github.com/bcicen/ctop  23.46s user 9.85s system 94% cpu 35.074 total
MartinFalatic commented 6 years ago

Assuming you have go 1.11 and dep (I have 0.5.0) installed, when you run go get github.com/bcicen/ctop you'll apparently get that error - I got these:

# github.com/bcicen/ctop/widgets
go/src/github.com/bcicen/ctop/widgets/input.go:67:25: e.Path undefined (type termui.Event has no field or method Path)
go/src/github.com/bcicen/ctop/widgets/status.go:32:2: undefined: termui.DefaultEvtStream
go/src/github.com/bcicen/ctop/widgets/status.go:33:8: undefined: termui.DefaultEvtStream
# github.com/bcicen/ctop/cwidgets/single
go/src/github.com/bcicen/ctop/cwidgets/single/cpu.go:23:11: cannot use tmpData (type []float64) as type map[string][]float64 in assignment
go/src/github.com/bcicen/ctop/cwidgets/single/cpu.go:26:11: cannot use cpu.hist.Data (type []float64) as type map[string][]float64 in assignment

However, when I cd go/src/github.com/bcicen/ctop and make build, I do end up with a ctop executable.

(This is on OS X with go and dep installed via brew using the default GOPATH - I've heard that non-default GOPATH may cause other issues...)

bcicen commented 5 years ago

ctop has a module definition to ensure you're using the right dependency versions -- follow the build doc to ensure go mod download is run before build

mrichman commented 5 years ago

Still failing:

# github.com/bcicen/ctop/cwidgets/single
../go/src/github.com/bcicen/ctop/cwidgets/single/cpu.go:23:11: cannot use tmpData (type []float64) as type map[string][]float64 in assignment
../go/src/github.com/bcicen/ctop/cwidgets/single/cpu.go:26:11: cannot use cpu.hist.Data (type []float64) as type map[string][]float64 in assignment
bcicen commented 5 years ago

What version of Go and value of env var $GO111MODULE? As this is a module, the repo must exist outside your $GOPATH

Also, please ensure you are on the latest master commit -- it looks like you are on an old commit and trying to build inside gopath.

mrichman commented 5 years ago

My error, sorry.

Using Go 1.11.4 on mojave

I did a git clone into ~/github/bcicen/ctop and then it works fine:

$ make build
go mod download
go: finding github.com/coreos/go-systemd v0.0.0-20151104194251-b4a58d95188d
go: finding github.com/Sirupsen/logrus v0.0.0-20150423025312-26709e271410
go: finding github.com/golang/protobuf v0.0.0-20170712042213-0a4f71a498b7
go: finding github.com/fsouza/go-dockerclient v0.0.0-20170307141636-318513eb1ab2
go: finding github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5
go: finding github.com/maruel/panicparse v0.0.0-20170227222818-25bcac0d793c
go: finding github.com/opencontainers/runc v0.1.1
go: finding github.com/bcicen/termui v0.0.0-20180326052246-4eb80249d3f5
go: finding github.com/hashicorp/go-cleanhttp v0.0.0-20170211013415-3573b8b52aa7
go: finding golang.org/x/net v0.0.0-20170308210134-a6577fac2d73
go: finding golang.org/x/sync v0.0.0-20181108010431-42b317875d0f
go: finding github.com/syndtr/gocapability v0.0.0-20150716010906-2c00daeb6c3b
go: finding github.com/op/go-logging v0.0.0-20160211212156-b2cb9fa56473
go: finding github.com/mattn/go-runewidth v0.0.0-20170201023540-14207d285c6c
go: finding github.com/maruel/ut v1.0.0
go: finding github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7
go: finding github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d
go: finding github.com/vishvananda/netlink v0.0.0-20150820014904-1e2e08e8a2dc
go: finding github.com/docker/go-units v0.3.2
go: finding github.com/Azure/go-ansiterm v0.0.0-20160622173216-fa152c58bc15
go: finding golang.org/x/sys v0.0.0-20170308153327-99f16d856c98
go: finding github.com/jgautheron/codename-generator v0.0.0-20150829203204-16d037c7cc3c
go: finding github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc
go: finding github.com/nsf/termbox-go v0.0.0-20180303152453-e2050e41c884
go: finding github.com/Microsoft/go-winio v0.3.8
go: finding github.com/docker/docker v0.0.0-20170502054910-90d35abf7b35
go: finding github.com/docker/go-connections v0.0.0-20170301234100-a2afab980204
go: finding github.com/seccomp/libseccomp-golang v0.0.0-20150813023252-1b506fc7c24e
go: finding github.com/godbus/dbus v0.0.0-20151105175453-c7fdd8b5cd55
go: finding github.com/c9s/goprocinfo v0.0.0-20170609001544-b34328d6e0cd
go: finding github.com/gizak/termui v2.3.0+incompatible
CGO_ENABLED=0 go build -tags release -ldflags "-w -X main.version=0.7.2 -X main.build=9592de8 -extldflags="-Wl,--allow-multiple-definition"" -o ctop
bcicen commented 5 years ago

glad you've got it working; closing for now