blob: 6f1cf2f5ce3b4f5ccc8843c7bc0dd30ab3d7620c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# Go Langugage Standards
## Definitions
- A `Program` is a program, service, or application which is NOT a library.
- A `Library` is code designed only for consumption by other programs.
## Requirements
- Builds MUST use the [Go-provided compiler][1].
Builds MUST NOT use the [gcc-go][2] compiler or other alternatives.
- Programs MUST update and commit the `go.mod` and `go.sum` using `go mod tidy`.
- Programs MUST [vendor dependency code][4] and commit the vendored code to their repository.
- CI builds MUST use the [golangci-lint][5] linter as a first-stage validation step
- Programs SHOULD use the [standard project layout][3]
- Programs MUST NOT use CGO unless there is no pure-Go alternative.
Appropriate uses of CGO include Oracle DB drivers, GPGPU computation.
(Prefer `CGO_ENABLED=0` as a build flag.)
## Recommended Resources
- [Effective Go](https://golang.org/doc/effective_go.html)
- [Go Proverbs](https://go-proverbs.github.io/)
- [Go Test package](https://pkg.go.dev/testing)
## Supplemental Advice
### Local Environment
- Run `go build`, `golangci-lint run`, and `go test` before pushing code for your PR.
- Fork the repository, then commit and push changes to the fork frequently.
This avoids catastrophic data loss and enables Work In Progress (WIP) sharing.
### Go language
- Errors MUST be handled
- Programs and Libaries SHOULD NOT use third-party libraries.
Prefer standard library packages.
- Use [gofumports](https://github.com/mvdan/gofumpt) for formatting and automatic imports
- Test functions MUST check both the error result and the returned data.
[RFC2119]:https://www.rfc-editor.org/rfc/rfc2119.txt
[1]:https://golang.org
[2]:https://gcc.gnu.org/onlinedocs/gccgo/
[3]:https://github.com/golang-standards/project-layout
[4]:https://golang.org/ref/mod#vendoring
[5]:https://golangci-lint.run
|