I am trying to add an external package to my go smartcontract (for installation , I ran : go get github.com/stripe/stripe-go) . I then imported files stripe "github.com/stripe/stripe-go" and charge "github.com/stripe/stripe-go/charge" , in my smartcontract (https://github.com/stripe/stripe-go). However, when I try to bring up my chaincode , I am getting the error :
Error: Error getting chaincode code chaincode: Error getting chaincode package bytes: Error obtaining dependencies for github.com/stripe/stripe-go: : failed with error: "exit status 1"
can't load package: package github.com/stripe/stripe-go: cannot find package "github.com/stripe/stripe-go" in any of:
/opt/go/src/github.com/stripe/stripe-go (from $GOROOT)
/opt/gopath/src/github.com/stripe/stripe-go (from $GOPATH)
I tried adding the package through govendor (http://hyperledger-fabric.readthedocs.io/en/release-1.0/Style-guides/go-style.html) , but that also is not working .
Request you all to please hep me on this . Thanks in advance.
I had the similar issue.
Govendor worked for me:
error getting chaincode package bytes: Error obtaining dependencies for github.com/go-ozzo/ozzo-validation/is
govendor add github.com/go-ozzo/ozzo-validation/is
govendor update +v
go build
And result was good:
Chaincode is installed on remote peer PEER2
UPDATE:
If you have a problem with vendor packages setup, here you go:
create folder vendor in project root directory with empty valid json file (vendor.json)
run command govendor add +external from root directory
you can also update all dependencies with update command.
Related
i have been trying to use iota connector with hyperledger fabric but when i try to build chaincode i get this error.
Error: error getting chaincode deployment spec for enter code herefabric-demo-app: error getting chaincode package bytes: failed to calculate dependencies: incomplete package: google.golang.org/protobuf/encoding/prototext
any idea why this happens?
I have tried to install the module using go install, but it appears that if it is installed.
If so, I would greatly appreciate a helping hand :)
I created a chaincode and I imported a package to it.
import (
"bytes"
"encoding/json"
"fmt"
"strings"
"golang.org/x/crypto/bcrypt"
"github.com/hyperledger/fabric/core/chaincode/shim"
pb "github.com/hyperledger/fabric/protos/peer")
I can install that chaincode to all endorsers. But when I instantiated it to all endorsers, it faced the error:
endorser failed with error starting container: error starting container: Failed to generate platform-specific docker build: Error returned from build: 1 "/chaincode/input/src/github.com/marbles02/marbles_chaincode.go:85:2: cannot find package "golang.org/x/crypto/bcrypt" in any of:
/usr/local/go/src/golang.org/x/crypto/bcrypt (from $GOROOT)
/chaincode/input/src/golang.org/x/crypto/bcrypt (from $GOPATH)
/go/src/golang.org/x/crypto/bcrypt
I tried to copy golang.org/x/crypto/bcrypt package to the /usr/local/go/src/ in the root directory, but it has the same error.
Try Installing the dependencies in the chaincode directory using below commands:
go mod init will create go.mod and go.sum files.
go mod vendor for creating a vendor directory.
Also if using fabric:v2.X.X then shim and peer packages moved to different libraries.
so change the peer and shim packages to below in the chaincode.go file.
peer --> github.com/hyperledger/fabric-protos-go/peer.
shim --> github.com/hyperledger/fabric-chaincode-go/shim
Make sure to add peerand shim changes before running go mod initcommand OR if you are already have a vendor directory then try go mod tidy and then go mod vendor commands to update the packages.
I am trying to add reflection to my working Go-based gRPC. I am getting an error when I try to fetch the reflection package:
$ GO111MODULE=on go get google.golang.org/grpc/reflection
go: github.com/google/go-github#v0.0.0-20190119011113-56cb1dd99043: go.mod has post-v0 module path "github.com/google/go-github/v21" at revision 56cb1dd99043
go: error loading module requirements
I can't find any reference to "go-github/v21" anywhere in my source, or in any of the packages in my GOPATH.
I also can't figure out what this error message means.
I am using Go version go1.11.5.
Thanks.
I had some issues with gopath configuration. I was able to resolve the go path issue. But getting this error...
[root#localhost mysqlbeat]# go get github.com/adibendahan/mysqlbeat
# github.com/adibendahan/mysqlbeat/beater
/root/go/src/src/github.com/adibendahan/mysqlbeat/beater/mysqlbeat.go:289:7: b.Events undefined (type *beat.Beat has no field or method Events)
/root/go/src/src/github.com/adibendahan/mysqlbeat/beater/mysqlbeat.go:303:7: b.Events undefined (type *beat.Beat has no field or method Events)
/root/go/src/src/github.com/adibendahan/mysqlbeat/beater/mysqlbeat.go:326:5: b.Events undefined (type *beat.Beat has no field or method Events)
How do I correctly install go package along with all it's dependencies?
Update:
I downloaded the package and tried to run it.Different error this time...
[root#localhost mysqlbeat]# make
go build
can't load package: /root/go/src/src/github.com/adibendahan/mysqlbeat/main.go:8:2: non-standard import "github.com/adibendahan/mysqlbeat/beater" in standard package "src/github.com/adibendahan/mysqlbeat"
make: *** [build] Error 1
Check out the How to Build section on README.md on mysqlbeat.
mysqlbeat uses Glide for dependency management. Check this for installing glide.
After installing Glide, clone the mysqlbeat repository and run:
$ glide update --no-recursive
$ make
If you still want to import this repository by go get, clone the repo and then run go get ./... from its root directory.
I'm having trouble running the go install $(glide nv) command.
I run this command from within my project's folder within the src folder of the go workspace directoy
so basically I do :
%GOPATH%/src/my/project/ go install $(glide nv)
The error message I get is as follow :
can't load package: package $(glide: cannot find package "$(glide" in any of:
C:\Go\src\$(glide (from $GOROOT)
W:\GO_WORKSPACE\src\$(glide (from $GOPATH)
can't load package: package nv): cannot find package "nv)" in any of:
C:\Go\src\nv) (from $GOROOT)
W:\GO_WORKSPACE\src\nv) (from $GOPATH)
I had previously run glide install without a problem on that project.
What am I missing?
It works on powershell. At the project directory run command:
go install $(glide nv)