Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Okstad <pokstad@gitlab.com>2019-12-17 14:11:35 +0300
committerJacob Vosmaer <jacob@gitlab.com>2019-12-17 14:11:35 +0300
commit3960ba1e4ce037a93b953b1e595a1893e9827c5f (patch)
tree58e0d55b95b604dcd31cb5b8253ebbfabb8d7e1e
parent27703f4874296dfe9c346c80d175c36b2a5e71e1 (diff)
Add style guide for Go import declarations
-rw-r--r--STYLE.md37
1 files changed, 37 insertions, 0 deletions
diff --git a/STYLE.md b/STYLE.md
index b9723778c..e011747e1 100644
--- a/STYLE.md
+++ b/STYLE.md
@@ -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