← 피드로
Been building goninja, a Go framework that generates CRUD REST APIs from annotated structs — routing, validation, OpenAPI, the rest.
It’s the Go counterpart to a Python project I already maintain, django-ninja-aio-crud — same idea, define the model once and get the API. Difference here: no runtime reflection, it generates real Go code that lives in your repo, readable like anything you’d write by hand.
hand.
type Book struct {
ID string `gorm:"primaryKey" goninja:"list,retrieve"`
Title string `goninja:"list,retrieve,create,update" validate:"required"`
AuthorID string `goninja:"list,retrieve,create,update,filter"`
Price float64 `goninja:"list,retrieve,create,update,filter" validate:"min=0"`
}
Enter fullscreen mode Exit fullscreen mode
$ goninja generate -models-import myapp/models
Enter fullscreen mode Exit fullscreen mode
추출 본문 · 출처: dev.to · https://dev.to/caspel26/goninja-code-first-crud-generation-for-go-no-reflection-41nm