Files
Go_I2p/CONTRIBUTING.md

61 lines
2.2 KiB
Markdown
Raw Permalink Normal View History

2016-06-19 15:23:01 -07:00
# Contributing
Thanks for taking a look at go-i2p! Please reach out if you have any questions or need help getting started.
## Getting Starting
Install required dependencies
This example assumes Ubuntu 16.04
```sh
sudo apt-get install pkg-config libsodium-dev
go get github.com/hkparker/go-i2p
2016-09-11 02:04:41 -04:00
go get github.com/Sirupsen/logrus
go get github.com/stretchr/testify/assert
```
2016-07-07 22:56:43 -07:00
Fork go-i2p and clone it into your workspace. Make sure you can execute `go test ./...` in the project's root directory. At that point you should have everything you need to start making changes and opening pull requests. If you aren't sure what to work on, take a look at some good [getting started issues](https://github.com/hkparker/go-i2p/issues?q=is%3Aopen+is%3Aissue+label%3A%22start+here%22).
2016-06-19 15:23:01 -07:00
## I2P Specifications
2016-06-19 15:41:23 -07:00
The I2P community maintains up-to-date [specifications](https://geti2p.net/spec) of most of the application, which are being used to create go-i2p. Currently, most the of common data structures (located in `lib/common/`) have been implemented and tested, and serve as good examples.
2016-06-19 15:23:01 -07:00
## Testing
`go test ./...`
## Conventions
2016-06-19 15:41:23 -07:00
#### Logging
2016-06-19 15:23:01 -07:00
Logrus is used for logging across all of go-i2p. All log statements should contain an `at` fields and a `reason` field. Here is a good example from the go-i2p implementation of a LeaseSet:
```go
2016-09-11 02:04:41 -04:00
log.WithFields(log.Fields{
2016-06-19 15:41:23 -07:00
"at": "(LeaseSet) PublicKey",
"data_len": remainer_len,
"required_len": LEASE_SET_PUBKEY_SIZE,
"reason": "not enough data",
2016-09-11 02:04:41 -04:00
}).Error("error parsing public key")
2016-06-19 15:23:01 -07:00
```
2016-06-19 15:41:23 -07:00
#### Testing
2016-06-19 15:23:01 -07:00
Testify is used to assert test cases in all tests in go-i2p for simplicity. Here is an example from the RouterInfo tests:
```go
func TestRouterAddressCountReturnsCorrectCount(t *testing.T) {
assert := assert.New(t)
router_info := buildFullRouterInfo()
count, err := router_info.RouterAddressCount()
assert.Nil(err)
assert.Equal(1, count, "RouterInfo.RouterAddressCount() did not return correct count")
}
```
## Pull Requests
Pull requests should pass all tests, test all new behavior, and be correctly formatted by `gofmt` before merge. Feel free to open incomplete pull requests if you are struggling, I will enthusiasticlly help you complete the PR in any way needed.