Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for backend development #17512

Merged
merged 7 commits into from
Nov 23, 2021
Merged

Conversation

lunny
Copy link
Member

@lunny lunny commented Nov 1, 2021

To clarify how the Gitea backend code organized, I propose the document to help contributors on writing backend codes.

@lunny lunny added type/docs This PR mainly updates/creates documentation pr/wip This PR is not ready for review labels Nov 1, 2021
docs/content/doc/developers/guidelines-backend.md Outdated Show resolved Hide resolved
docs/content/doc/developers/guidelines-backend.md Outdated Show resolved Hide resolved
docs/content/doc/developers/guidelines-backend.md Outdated Show resolved Hide resolved
docs/content/doc/developers/guidelines-backend.md Outdated Show resolved Hide resolved
docs/content/doc/developers/guidelines-backend.md Outdated Show resolved Hide resolved
docs/content/doc/developers/guidelines-backend.md Outdated Show resolved Hide resolved
docs/content/doc/developers/guidelines-backend.md Outdated Show resolved Hide resolved
docs/content/doc/developers/guidelines-backend.md Outdated Show resolved Hide resolved
docs/content/doc/developers/guidelines-backend.md Outdated Show resolved Hide resolved
docs/content/doc/developers/guidelines-backend.md Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Nov 1, 2021
@wxiaoguang
Copy link
Contributor

Some more things:

  • singular or not, eg: models/user vs models/users, models/issue vs models/issues
  • import alias, camelCase or snake_case

@lunny
Copy link
Member Author

lunny commented Nov 11, 2021

Some more things:

  • singular or not, eg: models/user vs models/users, models/issue vs models/issues
  • import alias, camelCase or snake_case
  • I like singular
  • I think snake_case is better to differ from variables.

@KN4CK3R
Copy link
Member

KN4CK3R commented Nov 11, 2021

I have a problem with singular in my package PR because package is a reserved word in Go, so I used packages. So I don't know if we can enforce this.

@wxiaoguang
Copy link
Contributor

Some more things:

  • singular or not, eg: models/user vs models/users, models/issue vs models/issues
  • import alias, camelCase or snake_case
* I like singular

* I think snake_case is better to differ from variables.

Both are fine to me. For singular, it's more likely to conflict with normal variable names. For example, usually we have alot of code like this user := GetUser(), then user.Xxx conflicts.

Since we can make an agreement, these points can be written into document, including how to name variables to prevent conflict, then we have a more clear review guideline.

@lunny
Copy link
Member Author

lunny commented Nov 22, 2021

  • singular

I'm ok for some special situations.

@lunny lunny removed the pr/wip This PR is not ready for review label Nov 22, 2021
@wxiaoguang
Copy link
Contributor

wxiaoguang commented Nov 22, 2021

LGTM, More points:

  1. db.WithTx seems easier than db.TxContext
  2. About error tracing (shared in the discord channel)
  3. A general method to do safe UPSERT

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Nov 22, 2021
@lunny
Copy link
Member Author

lunny commented Nov 22, 2021

LGTM, More points:

  1. db.WithTx seems easier than db.TxContext

  2. About error tracing (shared in the discord channel)

  3. A general method to do safe UPSERT

About the tracing, could you help to open an issue to describe the idea? And also if there is an example PR, that's great.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Nov 22, 2021
@lunny lunny merged commit b2daa7e into go-gitea:main Nov 23, 2021
@lunny lunny deleted the lunny/contribution branch November 23, 2021 02:10
Chianina pushed a commit to Chianina/gitea that referenced this pull request Mar 28, 2022
* Add documentation for backend development

* Update backend guidline

* More sections

* Add modules/setting and modules/git

* Uniform gitea as Gitea

* some improvements

* some improvements
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/docs This PR mainly updates/creates documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants