OpenAPITools / OpenAPITools/openapi-generator

[REQ] Improve go-gin-server template

Open
#7,280 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature Server: Go
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Hi, I'm gopher, as others already mentioned, go-gin-server has several issues.
I want to make points clear in this issue and discuss it.

Below is my suggestion as a gopher.

  • Locate source codes on the root (instead of under go directory)
  • Use separated package for controller or model.
  • Controller's implementation which based on request/response definition.
    • Bind body with shouldBind or get parameter with getParam etc...
    • Return success/error with the corresponding HTTP status and response body.
  • Defined routes with basic methods. Do not use the weird Route struct.
  • (Advanced) Add controller struct and define action methods for struct pointers.
    • By using controller struct, it's easier to initialize middleware in server bootstrapping.

I have my custom generator to achieve these points on my local already. I can refine it and make a PullReq if someone needs it.

Is it should have the same name or another? go-gin-server2?

Please give me advice and opinion.

I think it's related to #1931 and #2752, #2803. But I filed this issue because these are somewhat outdated.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing go-gin-server template and the related issues #1931, #2752, and #2803. Compare them with the proposed root layout, package separation, controller behavior, route definitions, and optional controller structs. The work is done when the desired template design is agreed and implemented in a pull request.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend-api-design, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.