If you are working on 0x-mesh, the root directory for the project must be at $GOPATH/src/github.com/0xProject/0x-mesh. 0x Mesh uses Dep for dependency management and does not support Go modules.
0x Mesh uses two main branches:
- The
development
branch contains the latest (possibly unreleased) changes and is not guaranteed to be stable. - The
master
branch contains the latest stable release.
If you intend to fork 0x Mesh and open a PR, you should work off of the
development
branch. Make sure you check out the development
branch and pull
the latest changes.
git checkout development
git pull
All PRs should use development
as the base branch. When opening a new PR, use
the dropdown menu in the GitHub UI to select development
.
- GNU Make If you are using a Unix-like OS, you probably already have this.
- Go version 1.12.x (or use the version manager called "g"). Go 1.13 is not supported yet (see 0xProject#480).
- Dep package manager
- Node.js version >=11 (or use the nvm version manager)
- Yarn package manager
- golangci-lint version 1.16.0
make deps
Some of the tests depend on having a test Ethereum node running. Before running
the tests, make sure you have Docker
installed locally and start
0xorg/ganache-cli. In these commands,
$GANACHE_VERSION
should be set to the version of ganache-cli that is used in the mesh project's
CI found here:
docker pull 0xorg/ganache-cli
# Run the $GANACHE_VERSION image of ganache-cli.
docker run -ti -p 8545:8545 -e VERSION=$GANACHE_VERSION 0xorg/ganache-cli
There are various Make targets for running tests:
# Run tests in pure Go
make test-go
# Compile to WebAssembly and run tests in Node.js
make test-wasm-node
# Compile to WebAssembly and run tests in a headless Chrome browser
make test-wasm-browser
# Run tests in all available environments
make test-all
The default maximum number of open files is too low in some operating systems
for the tests to be run successfully. If an error that reads like "Too many open files,"
it may be necessary to increase this limit. On Unix-like operating systems, the ulimit
command can be used as follows to accomplish this change:
# Increase number of open files that are tolerated to 2048 (a big number)
ulimit -S -n 2048
It may be convenient to add this line to the .bashrc
(or .bash_profile
for MacOs users)
file so that the change will go into effect whenever a new shell is created.
0x Mesh is configured to use linters for both Go and TypeScript code. To run all available linters, run:
make lint
See https://golang.github.io/dep/docs/daily-dep.html.
For VS Code, the following editor configuration is recommended:
{
// ...
"editor.formatOnSave": true,
"go.formatTool": "goimports",
"go.lintTool": "golangci-lint",
"go.lintOnSave": "package",
"go.vetOnSave": "off"
// ...
}
When working on code with the build tag js,wasm
, you might need to add the
following to your editor config:
{
// ...
"go.toolsEnvVars": {
"GOARCH": "wasm",
"GOOS": "js"
},
"go.testEnvVars": {
"GOARCH": "wasm",
"GOOS": "js"
}
// ...
}