<ahref="https://github.com/go-i2p/go-i2p"target="_blank">View on GitHub</a>
</div>
</nav>
<divclass="main-content">
<headerclass="page-header">
<h1>Contributing - go-i2p/go-i2p</h1>
</header>
<main>
<divclass="doc-content">
<h1id="contributing">Contributing</h1>
<p>Thanks for taking a look at go-i2p! Please reach out if you have any questions or need help getting started. We have an IRC channel on IRC2P: #go-i2p-dev and we’re reachable here at github.com/go-i2p also.</p>
<h2id="getting-started">Getting Started</h2>
<p>Install required dependencies</p>
<p>This example assumes Ubuntu or Debian based Linux, a reasonably modern version.
The instructions will be similar for other Linux distributions with slightly different package managers and package names.</p>
<pre><codeclass="language-sh"># For obtaining, modifying, compiling, and tracking changes to go-i2p, install:
sudo apt-get install golang-go make git
# If you want to generate markdown versions of the godoc locally, also install:
go install github.com/robertkrimen/godocdown/godocdown@master
# If you want to generate call graphs locally, also install:
go install github.com/ofabry/go-callvis@master
</code></pre>
<p>On Windows, one must install the latest versions of Go and Git Bash from their respective sources.</p>
<h2id="set-up-your-workspace">Set up your workspace:</h2>
<p>Fork go-i2p and clone it into your workspace. Make sure you can execute <code>go test ./...</code> in the project’s root directory. At that point you should have everything you need to start making changes and opening pull requests.</p>
<p>The I2P community maintains up-to-date <ahref="https://geti2p.net/spec"target="_blank">specifications</a> of most of the application, which are being used to create go-i2p. Currently, most the of common data structures (located in <code>lib/common/</code>) have been implemented and tested, and serve as good examples.</p>
<h2id="testing">Testing</h2>
<p><code>go test ./...</code></p>
<h2id="conventions">Conventions</h2>
<h4id="errors">Errors</h4>
<p>We use oops to provide context to the errors we return. Do not use <code>errors.New</code> or <code>fmt.Errorf</code> when returning errors from functions. Instead, wrap raw errors in oops errors. When an error is recieved, used oops to supplement the log output.</p>
<p>It is OK to use <code>fmt.Errorf</code> for declaring custom error types.</p>
<h4id="logging">Logging</h4>
<p>Logrus is used for logging across all of go-i2p. We have a small extension of logrus at <ahref="https://github.com/go-i2p/logger"target="_blank">https://github.com/go-i2p/logger</a> which we use to add a “Fail Fast mode.” We are mostly converted over to using it.</p>
<p>All log statements should contain an <code>at</code> fields and a <code>reason</code> field. Here is a good example from the go-i2p implementation of a LeaseSet:</p>
assert.Equal(1, count, "RouterInfo.RouterAddressCount() did not return correct count")
}
</code></pre>
<h2id="pull-requests">Pull Requests</h2>
<p>Pull requests should pass all tests, test all new behavior, and be correctly formatted by <code>gofumpt -w -s -extra</code> before merge. Feel free to open incomplete pull requests and ask for help and advice.</p>