Straight copy from the GitHub issue I was going to submit
(Which later on I thought that this would have been a better place)
What version of Go are you using (
$ go version go version go1.14.2 linux/amd64
Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
Debian 10 Buster Stable, Intel® Pentium® G4600 (x86_amd64)
$ uname -a Linux debian-homepc.bryanpedini.home 4.19.0-8-amd64 #1 SMP Debian 4.19.98-1+deb10u1 (2020-04-27) x86_64 GNU/Linux
go env Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/bryanpedini/.cache/go-build" GOENV="/home/bryanpedini/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/bryanpedini/projects/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build004077584=/tmp/go-build -gno-record-gcc-switches"
What did you do?
Currently trying to implement some APIs on top of an Echo framework instance on my home development PC.
Go environment always worked perfectly (all tho I don’t code that much myself, I’m still at “standard library level”, so I never needed to use versioned packages before), but now it started making a bundled mess with the package versions.
A simple, trimmed down version of the code I’m trying to execute: (without
ini config files and stuff)
https://play.golang.org/p/IfCwkwtZAew (and it doesn’t work)
The output from my PC:
$ go get -u gopkg.in/labstack/echo.v4 $ go run main.go register.go user.go ../../../gopkg.in/labstack/echo.v4/middleware/basic_auth.go:8:2: cannot find package "github.com/labstack/echo/v4" in any of: /usr/local/go/src/github.com/labstack/echo/v4 (from $GOROOT) /home/bryanpedini/projects/go/src/github.com/labstack/echo/v4 (from $GOPATH) $ go get -u github.com/labstack/echo/v4 package github.com/labstack/echo/v4: cannot find package "github.com/labstack/echo/v4" in any of: /usr/local/go/src/github.com/labstack/echo/v4 (from $GOROOT) /home/bryanpedini/projects/go/src/github.com/labstack/echo/v4 (from $GOPATH) $ go get -u github.com/labstack/echo $ go run main.go register.go user.go # command-line-arguments ./main.go:13:38: cannot use middleware.RemoveTrailingSlash() (type "github.com/labstack/echo".MiddlewareFunc) as type "gopkg.in/labstack/echo.v4".MiddlewareFunc in argument to e.Pre
A slightly modified version:
https://play.golang.org/p/1PhlgeDA32V (which goes on timeout, clear sign to me that the Echo server started)
And finally, the result of that same code on my computer (just changing the imports basically):
$ go run main.go register.go user.go main.go:7:2: cannot find package "github.com/labstack/echo/v4" in any of: /usr/local/go/src/github.com/labstack/echo/v4 (from $GOROOT) /home/bryanpedini/projects/go/src/github.com/labstack/echo/v4 (from $GOPATH) main.go:8:2: cannot find package "github.com/labstack/echo/v4/middleware" in any of: /usr/local/go/src/github.com/labstack/echo/v4/middleware (from $GOROOT) /home/bryanpedini/projects/go/src/github.com/labstack/echo/v4/middleware (from $GOPATH)
And on VSCode linter (Microsoft’s own extension for Go) I get the same “could not import github/labstack/echo/v4 (no package for import github/labstack/echo/v4)”…
And last but not least, let’s try without a version, shall we? Linter vs Compiler… FIGHT:
The linter goes first with an uppercat
And then the Echo microserver takes the linter KO, 'cause actually runs fine… like, WHAT?
What did you expect to see?
An easy to use versioning system called
What did you see instead?
A mess of something I can’t describe almost never working with hard to guess import paths that sometimes work, sometimes won’t (and a general lack of understanding of my issues by Google’s search function’s fault: what part of “I can import go packages from github but not from gopkg” you didn’t get stupid AI? just find my 2003 forum post, okay? cit. Wisdom of the Ancients)
End of GH issue copy
Is there anything more I should try / need to know before diving in, in getting some more headakes due to my (not/mis)understanding of how Go packages work?
Does anybody know like a guide or something easy to “get in the thinking system”? Because the language itself is pretty straight forward, very much Cpp-like and (for me) easy to start understanding and writing right away… but the technical scheme, man!! To place files in an “src” folder and then a directory with the name of the git platform and then your username and finally the project name, well, that was easy; but yooo boy if I ever understood a needle of what every tutorial I watched was saying about packages, their structure and their import schemes (now more than ever with the (almost) new introduction of package modules’ versioning)…
Thanks to everybody in advance, and sorry for the papirus (as said, it was a copypaste from the GitHub issue template and it’s very detailed).