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 ./...
Related
C:\Users\Administrator\Documents\code\projects\weatherly>go get -u github.com/gofiber/fiber/v2
cannot find package "github.com/gofiber/fiber/v2" in any of:
c:\go\src\github.com\gofiber\fiber\v2 (from $GOROOT)
C:\Users\Administrator\go\src\github.com\gofiber\fiber\v2 (from $GOPATH)
How do I download the package? I believe that it is trying to check what is cached on my computer and I don't know how to download it first.
Its because you haven't initiated your module, you should use go mod init YourModuleName, then its pretty simple to do. also remove -f from go get command.
I was migrating my Golang programs from windows to Centos 7
It worked perfectly in Windows
but when I tried to compile on centos I get errors like
main.go:20:3: cannot find package "github.com/BurntSushi/toml" in any of:
/usr/local/go/src/github.com/BurntSushi/toml (from $GOROOT)
/root/work/src/github.com/BurntSushi/toml (from $GOPATH)
main.go:15:3: cannot find package "github.com/dgrijalva/jwt-go" in any of:
/usr/local/go/src/github.com/dgrijalva/jwt-go (from $GOROOT)
/root/work/src/github.com/dgrijalva/jwt-go (from $GOPATH)
main.go:16:3: cannot find package "github.com/gwlkm_service/config" in any of:
/usr/local/go/src/github.com/gwlkm_service/config (from $GOROOT)
/root/work/src/github.com/gwlkm_service/config (from $GOPATH)
kinda new to centos so idk what to do
looks like you have configured your GOPATH, without Go Module, you can use go get [package path] to download imported packages.
go get github.com/BurntSushi/toml
go get github.com/dgrijalva/jwt-go
go get github.com/gwlkm_service/config
Precisely
your go installation on server seems in /usr/local/go and
your project is in /root/work
so all your dependencies should be either in /root/work/src or /usr/local/go/src
now coming to action check your GOPATH with running echo $GOPATH
assuming it is automatically set to /usr/local/go/src
If not then follow - How do I SET the GOPATH environment variable on Ubuntu? What file must I edit?
If everything is ok then in your folder run go mod init
this will create mod file which will help you in further installations
look into - https://blog.golang.org/using-go-modules
then run go get commands as above #beiping96 said
go get github.com/BurntSushi/toml
go get github.com/dgrijalva/jwt-go
go get github.com/gwlkm_service/config
NOTE - after completing above process you will generate go modules file(same as package.json) and in future you won't need to care about dependencies
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.
I am trying to follow instructions on Chaincode Development Environment to setup hyperledger in my local environment.
Unfortunately, I am completely new to golang. When I come across an error trying to build "chaintool/example02" I have no idea how to proceed further - should I ignore the issue or first I should fix something? For example, to run make with some options, etc ... How can I get missing imports ?
The output looks as follows:
hyper-00:chaincode hyper$ pwd
/Users/hyper/Projects/blockchain/src/github.com/hyperledger/fabric/examples/chaincode/chaintool/example02/src/chaincode
hyper-00:chaincode hyper$ go build ./
chaincode_example02.go:24:2: cannot find package "hyperledger/cci/appinit" in any of:
/Users/hyper/Projects/blockchain/src/github.com/hyperledger/fabric/vendor/hyperledger/cci/appinit (vendor tree)
/usr/local/go/src/hyperledger/cci/appinit (from $GOROOT)
/Users/hyper/Projects/blockchain/src/hyperledger/cci/appinit (from $GOPATH)
chaincode_example02.go:25:2: cannot find package "hyperledger/cci/org/hyperledger/chaincode/example02" in any of:
/Users/hyper/Projects/blockchain/src/github.com/hyperledger/fabric/vendor/hyperledger/cci/org/hyperledger/chaincode/example02 (vendor tree)
/usr/local/go/src/hyperledger/cci/org/hyperledger/chaincode/example02 (from $GOROOT)
/Users/hyper/Projects/blockchain/src/hyperledger/cci/org/hyperledger/chaincode/example02 (from $GOPATH)
chaincode_example02.go:26:2: cannot find package "hyperledger/ccs" in any of:
/Users/hyper/Projects/blockchain/src/github.com/hyperledger/fabric/vendor/hyperledger/ccs (vendor tree)
/usr/local/go/src/hyperledger/ccs (from $GOROOT)
/Users/hyper/Projects/blockchain/src/hyperledger/ccs (from $GOPATH)
hyper-00:chaincode hyper$
My $GOPATH gives:
hyper-00:~ hyper$ echo $GOPATH
/Users/hyper/Projects/blockchain
[EDITED on 2017-01-02]
I repeated the repo cloning procedure again.
I think my mistake was I pulled a wrong source from GitHub - probably "master", not "v0.6".
What I did and the compilation works now is:
$ sudo apt install golang-go
$ gedit .profile
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/Projects/blockchain
$ . ~/.profile
$ mkdir -p $GOPATH/src/github.com/hyperledger/
$ cd $GOPATH/src/github.com/hyperledger
$ git clone -b v0.6 http://gerrit.hyperledger.org/r/fabric
$ cd ~/Projects/blockchain/src/github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
$ go build
github.com/hyperledger/fabric should have included all these dependencies in its vendor/ folder or put the examples in their own repo with a vendor folder, so this looks like their problem not yours.
You can fix it by running go get x y z for all missing packages, or try using a vendoring tool to get them.
There are many options for vendoring but no "official" option until next year. I prefer govendor. i havent tried it with this particular repo but you can try with:
go get -u github.com/kardianos/govendor
cd /Users/hyper/Projects/blockchain/src/github.com/hyperledger/fabric/
govendor fetch -v +missing
The HyperLedger team has provided very good documentation on how to use chaintool in a manner that allows users to document APIs (via Chain Code Interface, or CCI). Without this, consumers of a chaincode must inspect source code to understand how to compose a REST invocation. Great idea.
This approach to building chaincode requires you download github.com/hyperledger/cci and github.com/hyperledger/ccs to reside next to github.com/hyperledger/fabric within your $GOPATH. Unfortunately, I don't see any repository (on either github or gerrit) where this can be downloaded.
Further, I've only seen one example (thus far) of how to use chaintool with cci and ccs, which is chaintool/example02... and it does not compile due to these missing hyperledger packages.
There is documentation on chaintool with cci/ccs support at the following location:
https://github.com/hyperledger/fabric-chaintool
But it seems this documentation has been copied to the following location and renamed from 'chaintool' to 'openblockchain compiler' (or OBCC) and labeled as a 'work in progress':
https://libraries.io/github/hyperledger/fabric-chaintool
As such, I am inclined to believe the chaintool/example02 is not a currently supported approach to building chaincode... at least until OBCC becomes officially available.
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.