-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
149 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
# Hacking guidelines | ||
|
||
## Developer dependencies | ||
|
||
To develop httpexpect, you need: | ||
|
||
* [golangci-lint](https://golangci-lint.run/usage/install/#local-installation) | ||
|
||
* [stringer](https://github.com/golang/tools) | ||
|
||
`go install golang.org/x/tools/cmd/stringer@latest` | ||
|
||
## Makefile targets | ||
|
||
Re-generate, build, lint, and test everything: | ||
|
||
``` | ||
make | ||
``` | ||
|
||
Run tests: | ||
|
||
``` | ||
make test | ||
``` | ||
|
||
Run only short tests: | ||
|
||
``` | ||
make short | ||
``` | ||
|
||
Run gofmt: | ||
|
||
``` | ||
make fmt | ||
``` | ||
|
||
Run go generate: | ||
|
||
``` | ||
make gen | ||
``` | ||
|
||
Run go mod tidy: | ||
|
||
``` | ||
make tidy | ||
``` | ||
|
||
## Comment formatting | ||
|
||
Exported functions should have documentation comments, formatted as follows: | ||
|
||
* short function description, indented with one SPACE | ||
* empty line | ||
* optional details, indented with one SPACE | ||
* empty line | ||
* `Example:` line, indented with one SPACE | ||
* empty line | ||
* example code, indented with one TAB | ||
* no more empty lines | ||
|
||
**GOOD:** | ||
|
||
```go | ||
// Short function description. | ||
// | ||
// Optional details, probably multiple | ||
// lines or paragraphs. | ||
// | ||
// Example: | ||
// | ||
// exampleCode() | ||
func MyFunction() { ... } | ||
``` | ||
|
||
**BAD:** no space after `//`: | ||
|
||
```go | ||
//Short function description. | ||
// | ||
// Example: | ||
// | ||
// exampleCode() | ||
func MyFunction() { ... } | ||
``` | ||
|
||
**BAD:** missing empty line before `Example:` | ||
|
||
```go | ||
// Short function description. | ||
// Example: | ||
// | ||
// exampleCode() | ||
func MyFunction() { ... } | ||
``` | ||
|
||
**BAD:** missing empty line after `Example:` | ||
|
||
```go | ||
// Short function description. | ||
// | ||
// Example: | ||
// exampleCode() | ||
func MyFunction() { ... } | ||
``` | ||
|
||
**BAD:** forgetting to indent example code: | ||
|
||
```go | ||
// Short function description. | ||
// | ||
// Example: | ||
// | ||
// exampleCode() | ||
func MyFunction() { ... } | ||
``` | ||
|
||
**BAD:** using spaces instead of TAB to indent example code: | ||
|
||
```go | ||
// Short function description. | ||
// | ||
// Example: | ||
// | ||
// exampleCode() | ||
func MyFunction() { ... } | ||
``` | ||
|
||
**BAD:** extra empty line between comment and function: | ||
|
||
```go | ||
// Short function description. | ||
// | ||
// Example: | ||
// | ||
// exampleCode() | ||
|
||
func MyFunction() { ... } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters