···101101Since there are some packages which use the same package name, it is possible that you find packages like `modules/user`, `models/user`, and `services/user`. When these packages are imported in one Go file, it's difficult to know which package we are using and if it's a variable name or an import name. So, we always recommend to use import aliases. To differ from package variables which are commonly in camelCase, just use **snake_case** for import aliases.
102102i.e. `import user_service "code.gitea.io/gitea/services/user"`
103103104104+### Implementing `io.Closer`
105105+106106+If a type implements `io.Closer`, calling `Close` multiple times must not fail or `panic` but return an error or `nil`.
107107+104108### Important Gotchas
105109106110- Never write `x.Update(exemplar)` without an explicit `WHERE` clause:
+4
modules/git/blame.go
···115115116116// Close BlameReader - don't run NextPart after invoking that
117117func (r *BlameReader) Close() error {
118118+ if r.bufferedReader == nil {
119119+ return nil
120120+ }
121121+118122 err := <-r.done
119123 r.bufferedReader = nil
120124 _ = r.reader.Close()
+4-3
modules/git/repo_base_gogit.go
···8888}
89899090// Close this repository, in particular close the underlying gogitStorage if this is not nil
9191-func (repo *Repository) Close() (err error) {
9191+func (repo *Repository) Close() error {
9292 if repo == nil || repo.gogitStorage == nil {
9393- return
9393+ return nil
9494 }
9595 if err := repo.gogitStorage.Close(); err != nil {
9696 gitealog.Error("Error closing storage: %v", err)
9797 }
9898+ repo.gogitStorage = nil
9899 repo.LastCommitCache = nil
99100 repo.tagCache = nil
100100- return
101101+ return nil
101102}
102103103104// GoGitRepo gets the go-git repo representation