File tree Expand file tree Collapse file tree 2 files changed +35
-38
lines changed Expand file tree Collapse file tree 2 files changed +35
-38
lines changed Original file line number Diff line number Diff line change @@ -41,4 +41,38 @@ var Migrations embed.FS
41
41
42
42
## Import packages
43
43
44
- TBD
44
+ All package import paths must be valid Go Modules path except packages from standard library.
45
+
46
+ Generally, there are four types of packages a source file could import:
47
+
48
+ 1 . Packages from standard library
49
+ 2 . Third-party packages
50
+ 3 . Packages in the same organization but not in the same repository
51
+ 4 . Packages in the same repository
52
+
53
+ Basic rules:
54
+
55
+ - Use different groups to separate import paths by an blank line for two or more types of packages.
56
+ - Must not use ` . ` to simplify import path except in test files (` *_test.go ` ).
57
+ - Must not use relative path (` ./subpackage ` ) as import path.
58
+
59
+ Here is a concrete example:
60
+
61
+ ``` go
62
+ import (
63
+ " fmt"
64
+ " html/template"
65
+ " net/http"
66
+ " os"
67
+
68
+ " github.com/urfave/cli"
69
+ " gopkg.in/macaron.v1"
70
+
71
+ " github.com/gogs/git-module"
72
+
73
+ " github.com/gogs/gogs/internal/route"
74
+ " github.com/gogs/gogs/internal/route/repo"
75
+ " github.com/gogs/gogs/internal/route/user"
76
+ )
77
+ ```
78
+
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments