mirror of
https://github.com/go-i2p/go-i2p.git
synced 2025-07-17 13:54:33 -04:00
update readme adding contributing
This commit is contained in:
49
CONTRIBUTING.md
Normal file
49
CONTRIBUTING.md
Normal file
@ -0,0 +1,49 @@
|
||||
# Contributing
|
||||
|
||||
Thanks for taking a look at go-i2p! Please reach out if you have any questions or need help getting started.
|
||||
|
||||
## Getting Starting
|
||||
|
||||
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.
|
||||
|
||||
## I2P Specifications
|
||||
|
||||
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 a good examples.
|
||||
|
||||
## Testing
|
||||
|
||||
`go test ./...`
|
||||
|
||||
## Conventions
|
||||
|
||||
### Logging
|
||||
|
||||
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
|
||||
log.WithFields(log.Fields(
|
||||
"at": "(LeaseSet) PublicKey",
|
||||
"data_len": remainer_len,
|
||||
"required_len": LEASE_SET_PUBKEY_SIZE,
|
||||
"reason": "not enough data",
|
||||
)).Error("error parsing public key")
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
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.
|
Reference in New Issue
Block a user