Skip to content

Commit

Permalink
Added coding-style.md
Browse files Browse the repository at this point in the history
  • Loading branch information
thrasher- committed Aug 9, 2016
1 parent dbc15b3 commit c989991
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions doc/coding-style.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Coding Style
===============

In order to maintain a consistent style across the codebase, the following coding style has been adopted:

- Function names use PascalCase (func SomeFunc()).
- Function names using acronyms are capitilised (func SendHTTPRequest()).
- Variable names use CamelCase (var someVar()).
- Coding style uses gofmt.
- Const variables are capitilised.
- In line with gofmt, for loops and if statements don't require paranthesis.

Block style example:
```go
func SendHTTPRequest(method, path string, headers map[string]string, body io.Reader) (string, error) {
result := strings.ToUpper(method)

if result != "POST" && result != "GET" && result != "DELETE" {
return "", errors.New("Invalid HTTP method specified.")
}

req, err := http.NewRequest(method, path, body)

if err != nil {
return "", err
}

for k, v := range headers {
req.Header.Add(k, v)
}
...
}
```

0 comments on commit c989991

Please sign in to comment.