I normally use my Linux machine, running VS Code and the Go extension for all my Go projects. This works fine, however now i am using my work laptop which is unfortunately Windows based.
I have Windows 10 running on the laptop, along with VS Code and Go version 1.14.6. Not completely up to date, but no older than 6 months.
I have been completely unable to figure out how to download/install a particular library or package from github. Ordinarily this is a piece of cake on my Linux machine, however in Windows I can’t seem to get this to work.
When I run the code (which I know works, as I have seen it built and run on another machine) I get the following error:
main.go:6:2: cannot find package “github com/jedib0t/go-pretty/v6/table” in any of:
C:\Go\src\github.com\jedib0t\go-pretty\v6\table (from $GOROOT)
C:\Gowork\src\github.com\jedib0t\go-pretty\v6\table (from $GOPATH)
NOTE IGNORE THE MISSING DOT. Go forum refuses to let me put the dot between github and com in the error stated above!
If I try to run the following (or various derivatives of it) in the command line: go get github.com/jedib0t/...
It doesn’t come up with an error, and in fact appears to complete, but I still have no library to compile against.
If I try what makes more sense to me: go get github.com/jedib0t/go-pretty
I get told the following: go build github.com/jedib0t/go-pretty: no non-test Go files in C:\Gowork\src\github.com\jedib0t\go-pretty
What am I doing wrong in Windows? Why can’t I do something that is so straighforward in Linux?
Thanks NobbZ, I resolved the problem ultimately by using another machine. I suspect the key part I was possibly missing is cd’ing to my project directory prior to using go get (I never realized this was a requirement, and probably just got lucky over the last 6 months when using go get).
In terms of vendoring, while I understand what you mean, I am still not clear on how Go manages vendorization (IE what command do I run to ensure I have a library locally cloned or vendored? is go get xxx sufficient for this? Do I have to manually keep it up to date? is a vendored package unique to one project, or globally accessible to all projects?) I haven’t found a suitable online source that clearly answers questions like these.
Vendoring in legacy projects is a manual task, though tools exist that promise to help with this. I never used those.
Vendoring in modules is possible via a go command as I far as I know. Though I never actually used it, as the lockfile approach is sufficient in my team.