Add package.json back, to specify the dependencies on gx.
Add the python script scripts/update-gomod.py, which parses the dependency on gx, turns gx-hash to git commits, and updates them to go.mod and go.sum using go get.
There are two modes in this script: download, and update.
download: download and update all dependencies of the current repo according to the gx dependency file package.json, to the path /tmp/gx-git-repos.
update: parse the dependencies information described by package.json with BFS and get the gx versions in the format in the below for each dependency. Then, search for the git commit or release version with the gx information, in the downloaded repos which are fetched in mode download. Last, use those git commit or release version, we can do GO111MODULE=on go get {repo}@{commit or version} to update the versions to go.mod
$ cd {path/to/sharding-p2p-poc}
$ python scripts/update-gomod.py download # Download the git repos of all dependencies(including the indirect ones)
$ python scripts/update-gomod.py update
$ GO111MODULE=on go build
Current issues
[x] Haven't verified whether go get truly update the dependency to go.mod or not
[x] Seems the version specified in gx(package.json) is not necessarily equaled to the one in git tag
Note: I'd like to close this PR and reopen it after confirming all deps can be resolved correctly. Moved the script update-gomod.py to another repo https://github.com/mhchia/py-gx-gomod
What was wrong?
https://github.com/ethresearch/sharding-p2p-poc/issues/130
How was it fixed?
package.json
back, to specify the dependencies on gx.scripts/update-gomod.py
, which parses the dependency on gx, turns gx-hash to git commits, and updates them togo.mod
andgo.sum
usinggo get
.There are two modes in this script:
download
, andupdate
.download
: download and update all dependencies of the current repo according to the gx dependency filepackage.json
, to the path/tmp/gx-git-repos
.update
: parse the dependencies information described bypackage.json
with BFS and get the gx versions in the format in the below for each dependency. Then, search for the git commit or release version with the gx information, in the downloaded repos which are fetched in modedownload
. Last, use those git commit or release version, we can doGO111MODULE=on go get {repo}@{commit or version}
to update the versions togo.mod
Example
Current issues
go get
truly update the dependency togo.mod
or notpackage.json
) is not necessarily equaled to the one ingit tag
Reference
v2.7.3-gx-ipfs-Qmb3GBFCHMuzmi9EpH3pxpYBiviyc3tEPyDQHxZJQJSxj9
in https://github.com/whyrusleeping/gx/issues/200#issuecomment-413218625Cute Animal Picture