You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 30, 2018. It is now read-only.
I'm developing a chaincode program in my own repo (outside the fabric repo). I want to define a private function that accepts a parameter of type gp.Timestamp, where gp is package alias for google/protobuf. If I add vendor/google/protobuf (and its dependency vendor/github.com/golang/protobuf) dir to my repo, I get the following error about the colliding types:
./myexample.go:22: cannot use timestamp (type *"github.com/hyperledger/fabric/vendor/google/protobuf".Timestamp) as type "myorg/myexample/vendor/google/protobuf".Timestamp in argument to processTimetstamp
The reason here is that I'm importing shim as a library, but Go libraries should not have a vendor dir; but fabric has a vendor dir because it is also an executable.
A possible solution would be to create a new hyperledger/fabric-chaincode-shim project which includes only the shim package, without vendor. Then chaincode programs should only import that package. It might also save some space for the chaincode docker containers.
cd /opt/gopath/src/myorg/myexample
go build .
# myorg/myexample
./myexample.go:22: cannot use timestamp (type *"github.com/hyperledger/fabric/vendor/google/protobuf".Timestamp) as type "myorg/myexample/vendor/google/protobuf".Timestamp in argument to processTimetstamp
Notes
I can write code that uses stub.GetTxTimestamp() as long as I don't refer to the type gp.Timestamp by name. For example, this compiles OK:
Also, I think that it might be better for shim not to expose its protobuf internals. For example, GetTxTimestamp() could return a standard Go time.Time.
The text was updated successfully, but these errors were encountered:
Description
I'm developing a chaincode program in my own repo (outside the
fabric
repo). I want to define a private function that accepts a parameter of typegp.Timestamp
, wheregp
is package alias forgoogle/protobuf
. If I addvendor/google/protobuf
(and its dependencyvendor/github.com/golang/protobuf
) dir to my repo, I get the following error about the colliding types:The reason here is that I'm importing
shim
as a library, but Go libraries should not have a vendor dir; but fabric has a vendor dir because it is also an executable.A possible solution would be to create a new
hyperledger/fabric-chaincode-shim
project which includes only the shim package, without vendor. Then chaincode programs should only import that package. It might also save some space for the chaincode docker containers.Describe How to Reproduce
Inside the fabric vagrant:
And put the following content in
/opt/gopath/src/myorg/myexample/myexample.go
:Try to build:
Notes
I can write code that uses
stub.GetTxTimestamp()
as long as I don't refer to the typegp.Timestamp
by name. For example, this compiles OK:Also, I think that it might be better for
shim
not to expose its protobuf internals. For example,GetTxTimestamp()
could return a standard Gotime.Time
.The text was updated successfully, but these errors were encountered: