Skip to content

[REQ] Improve go-gin-server template #7280

Open
@ash-r1

Description

@ash-r1

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions