diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2019-12-17 14:11:36 +0300 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2019-12-17 14:11:36 +0300 |
commit | f0019cdaae96ee4fd8ee551cdc576c1424116e5b (patch) | |
tree | 58e0d55b95b604dcd31cb5b8253ebbfabb8d7e1e | |
parent | 27703f4874296dfe9c346c80d175c36b2a5e71e1 (diff) | |
parent | 3960ba1e4ce037a93b953b1e595a1893e9827c5f (diff) |
Merge branch 'po-doc-style-imports' into 'master'
Add style guide for Go import declarations
See merge request gitlab-org/gitaly!1697
-rw-r--r-- | STYLE.md | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -133,3 +133,40 @@ important to mitigate these injection risks: - Desired: `[]git.Flag{"-a"}` - Undesired: `[]git.Flag{foo}` is ambiguous and difficult to audit +## Go Imports Style + +When adding new package dependencies to a source code file, keep all standard +library packages in one contiguous import block, and all third party packages +(which includes Gitaly packages) in another contiguous block. This way, the +goimports tool will deterministically sort the packages which reduces the noise +in reviews. + +Example of **valid** usage: + +```go +import ( + "context" + "io" + "os/exec" + + "gitlab.com/gitlab-org/gitaly/internal/command" + "gitlab.com/gitlab-org/gitaly/internal/git/alternates" + "gitlab.com/gitlab-org/gitaly/internal/git/repository" +) +``` + +Example of **invalid** usage: + +```go +import ( + "io" + "os/exec" + + "context" + + "gitlab.com/gitlab-org/gitaly/internal/git/alternates" + "gitlab.com/gitlab-org/gitaly/internal/git/repository" + + "gitlab.com/gitlab-org/gitaly/internal/command" +) +```
\ No newline at end of file |