hyperledger-archives / sawtooth-sdk-go

https://wiki.hyperledger.org/display/sawtooth
Apache License 2.0
28 stars 40 forks source link

Convert to go module and rework protogen and imports #43

Closed wkatsak closed 3 years ago

wkatsak commented 3 years ago

Hello,

My goal here was to convert the sdk to a proper go module. Once I started down this path, I ended up having to fix some things with the way the compiled protobufs were included and references. To summarize, I've done the following:

1) Modified theDockerfile so it works on arm64 Mac/Linux (non-breaking change, repo weirdness). 2) Fixed a typo in gen.sh that caused old mocks were not being removed before generating new ones. 3) Changed all internal references to use full paths (both protobuf references and stuff inside the examples). 4) Add a cgo directive to the pem_loader to instruct it to use pkg-config to find openssl (this can be discussed...I don't think it will cause much problem at all on Linux, but is necessary to get it to use homebrew openssl on mac). 5) Regenerate the protobufs and mocks in protobuf and remove the copy at src/protobuf. 6) Finally, convert to go module by adding go.mod and go.sum.

I think the biggest 'disruption' here is the recompilation of the protobufs and the dropping of src/protobuf. Keep in mind that the stuff in src/protobuf (and even in protobuf in v0.1.3) did not actually work, as the references needed to be re-written as full paths (the user had to run go generate anyway!).

Now, the SDK can simply be downloaded/imported without calling go generate.

Please let me know if anyone has any comments or changes they would like.

-Bill

vaporos commented 3 years ago

Can you confirm that the README.md file instructions for updating the auto-generated files is accurate? (inc. the new sum file)

wkatsak commented 3 years ago

Can you confirm that the README.md file instructions for updating the auto-generated files is accurate? (inc. the new sum file)

This is correct, but is now only required for developers. I'll do a quick revision to the README that breaks down what is required for usage vs. development.

wkatsak commented 3 years ago

Ok, so I fixed the linter errors and added README.md updates.