go get ./... refuses to download gopkg.in/yaml.v2 - go

I'm just "getting" all required libraries by using go get ./... and go-get happily downloads all libs which are imported directly from github.com, however I get the error:
src/github.com/urfave/cli/altsrc/yaml_file_loader.go:17:2: cannot find package "gopkg.in/yaml.v2" in any of:
/home/ci/.jenkins/tools/org.jenkinsci.plugins.golang.GolangInstallation/Go_1.6/src/gopkg.in/yaml.v2 (from $GOROOT)
/home/ci/.jenkins/jobs/BlenderRender-Client/workspace/src/gopkg.in/yaml.v2 (from $GOPATH)
Sure, I could go get gopkg.in/yaml.v2 and it would work, however I'm setting up a CI server to automatically compile my project and I'd rather have go get ./... just download everything and not complain about gopkg.in-packets since I don't want to reconfigure my CI server every time some requirement changes.
Is there a way to tell go get ./... that it's fine to download gopkg.in packets?

Apparently you have issues with get, try go get -v gopkg.in/yaml.v2 and you'll face an error if you have git <=1.7.1
Just upgrade your git client, and problem fixed
You can also solve this by cloning the yaml.v2 repo into :
/home/ci/.jenkins/jobs/BlenderRender-Client/workspace/src/gopkg.in/yaml.v2
run a git clone https://github.com/go-yaml/yaml.git /home/ci/.jenkins/jobs/BlenderRender-Client/workspace/src/gopkg.in/yaml.v2

Related

Why "undefined: StackGuardMultiplierDefault" error?

describe
When I clone GoAdminGroup/go-admin projectin github and run the project by the steps of README.MD file , I get this error
TEST-MBP:example TEST$ GO111MODULE=on go run main.go
go: downloading github.com/mattn/go-sqlite3 v1.11.0
go: extracting github.com/mattn/go-sqlite3 v1.11.0
go: finding github.com/mattn/go-sqlite3 v1.11.0
# runtime/internal/sys
/Users/TEST/go/src/runtime/internal/sys/stubs.go:16:30: undefined: StackGuardMultiplierDefault
Actually my /Users/TEST/go/src folder was cloned from https://github.com/golang/go/tree/release-branch.go1.13/src
Why StackGuardMultiplierDefault was undefined in /src/runtime/internal/sys/stubs.go
As per my understanding you cloned the Go source code from it's github and expecting it to work. It will not work.
You need to to follow Go guide Installing Go from source if you want to install it from the (github) source. Only cloning the repository is not enough, there are some required steps to be done after that.
Otherwise I suggest to install by using the available binary distributions installer.
Detailed explanation: the const StackGuardMultiplierDefault is not found because the file where the const declared does not exists (the zversion.go file). This particular file is only generated when àll.bash is executed (part of steps on installling Go from source).

how to import package from github

I'm trying to build a api using Go and I tried running a existing file from GitHub that I got from udemy course. I'm getting this kind of output:
C:\goworkspace\src\grpc-go-course-master\blog\blog_client>go run client.go
client.go:4:2: cannot find package "context" in any of:
C:\go\src\context (from $GOROOT)
C:\goworkspace\src\context (from $GOPATH)
..\..\..\golang.org\x\net\http2\not_go111.go:10:2: cannot find package "net/http/httptrace" in any of:
C:\go\src\net\http\httptrace (from $GOROOT)
C:\goworkspace\src\net\http\httptrace (from $GOPATH)
Could you suggest me what can cause this error?
In order to download the dependencies, you have to use the go get command:
go get -v -u github.com/alessiosavi/GoUtils
Change with the package that you need (in that repo you can find a bunch of 'utils' method).
If the project, instead, have the go.mod file, you have to type:
go clean
go build
By this way you are going to install the dependencies listed in the go.mod file.
For update the dependencies to the latest version:
go get -v -u all
go mod tidy
The above command looks for missing dependencies, adds them to go.mod, and installs them.

go run/build not getting dependencies

go run and go build are not geting dependencies.
What I did:
I have done a go get of a package, it fetched it, and its dependencies, and build it. (all is good)
I run its command-line example program. (all is good)
I then created a new program based on this example, and go run it. (all is good)
Then copied this example program, and go run it. ( get a dependency error ).
Transcript
#↳ go version
go version go1.11.4 linux/amd64
#↳ echo $GOPATH
/home/????/+Files/workshops/programming/golang/gopath
#↳ go get -u github.com/cbroglie/mustache/...
#↳ cp -T $GOPATH/src/github.com/cbroglie/mustache/cmd/mustache/main.go my-mustache.go
#↳ go build -v my-mustache.go
my-mustache.go:8:2: cannot find package "github.com/spf13/cobra" in any of:
/usr/local/go/src/github.com/spf13/cobra (from $GOROOT)
/go/src/github.com/spf13/cobra (from $GOPATH)
I can see why it is not already installed: it was in a vendor sub-directory of the original source code. But why does it not install, when I build?
Check first your $GOPATH/bin folder: a go get -u github.com/cbroglie/mustache/... should already have compiled and installed all relevant binaries in it.
The README mentions:
To install mustache.go, simply run go get github.com/cbroglie/mustache/....
From the comments:
It looks like the mustache package is installed and working. However
when I try to build the cli example, it needs another package, if I go
get it then all is well, however I was expecting go build to install
all needed packages. Am I wrong?
go build itself won't install dependencies, so you need to go get it, or activate go 1.11 modules and declare that dependencies in your new program modules.

Unable to use Go get properly

I am a new user to go and I am trying this command.
go get github.com/tensorflow/tensorflow/tensorflow/contrib/go
And I am getting this error
package github.com/tensorflow/tensorflow/tensorflow/contrib/go
imports github.com/tensorflow/tensorflow/tensorflow/contrib/go
imports github.com/tensorflow/tensorflow/tensorflow/contrib/go: cannot find package "github.com/tensorflow/tensorflow/tensorflow/contrib/go" in any of:
/usr/lib/go/src/pkg/github.com/tensorflow/tensorflow/tensorflow/contrib/go (from $GOROOT)
/home/arafat/go/src/github.com/tensorflow/tensorflow/tensorflow/contrib/go (from $GOPATH)
I know this seems to be a trivial issue but I am stuck at it.
If the code to compile and install is not in the master branch (checked out by default by the go get), but only in the go branch of that repo, try and:
cd $GOPATH/github.com/tensorflow/tensorflow
git checkout go
Then try again the compilation.

Go get not fetching all dependencies

I am using go 1.5.1 on Windows 8.1 64-bit. I do not have GO15VENDOREXPERIMENT set in my environment. I have the latest version of git and bazaar installed.
I am trying to get the gomniauth package:
go get github.com/stretchr/gomniauth
Even though the process completes without any error, a lot of dependencies aren't pulled in.
For example, when compiling my app (which depends on gomniauth), I get these errors:
..\github.com\stretchr\codecs\xml\simple_xml_codec.go:5:2: cannot find package "github.com/clbanning/x2j" in any of:
C:\Go\src\github.com\clbanning\x2j (from $GOROOT)
C:\work\src\github.com\clbanning\x2j (from $GOPATH)
..\github.com\stretchr\codecs\msgpack\msgpack_codec.go:6:2: cannot find package "github.com/ugorji/go/codec" in any of:
C:\Go\src\github.com\ugorji\go\codec (from $GOROOT)
C:\work\src\github.com\ugorji\go\codec (from $GOPATH)
..\github.com\stretchr\codecs\bson\bson_codec.go:5:2: cannot find package "labix.org/v2/mgo/bson" in any of:
C:\Go\src\labix.org\v2\mgo\bson (from $GOROOT)
C:\work\src\labix.org\v2\mgo\bson (from $GOPATH)
It seems to pull in the direct dependencies for gomniauth, but doesn't pull in the dependencies of the dependencies. I have gone and deleted the stretchr folder from my GOPATH/src as well as GOPATH/pkg, but after running go get many times, it is still not pulling in the any dependencies beyond the second level.
I am 100% confident there are no network issues on my end. I can access those github repos using my browser or curl.
Change directory to your project and then try go get ./...
E.g.:
cd C:\work\src\github.com\stretchr\gomniauth
go get ./...
Or just go get github.com/stretchr/gomniauth/... as Amit Kumar Gupta suggested
In my case I was missing the bzr package.
After adding it using dnf install bzr and running #RoninDev suggestion it worked as expected:
cd $GOPATH/src/github.com/stretchr/gomniauth
go get ./...

Resources