This is an opinionated generator, to help build out and stub API for projects.
This generator is used to get a project up to speed as soon as possible with as little effort as possible.
The generation is opinionated, but trying to keep as little lock in as possible. You can use the generator to produce a single executable or the functions for a microservice architecture.
//go:generate go run github.com/team142/project-seedling -i user.go -version v1 -auth
package basic
// User is a basic user structure for the system
// @BasePath /api
// @Version
// #GET AUTH
// #POST AUTH
// #DELETE AUTH
type User struct {
//@API
//#PK
Id int `json:"id,omitempty"`
//@API
FirstName string `json:"first_name,omitempty"`
//@API
LastName string `json:"last_name,omitempty"`
//#Ignore
CreatedAt string `json:"-"`
}
go generate ./...
- DB to YAML
- YAML to struct
- YAML to DB
- YAML to DB changes
- Generate go files from templates
- Example: Struct Core Functions
- Example: Struct API Functions
- Example: API Client - This will generate a SDK to use the API's
- GO
- Everything must be driven from a struct ( including the struct tags )
- I don't believe it should be part of the CI process
- Although it can be
- Automagically create the functions for a web framework:
- Fiber -> https://github.com/gofiber/recipes/tree/master/clean-architecture
- Handlers
- Routers
- Presenters
- Common Middleware
- Fiber -> https://github.com/gofiber/recipes/tree/master/clean-architecture
- Auto Create the docs required for https://github.com/gofiber/recipes/tree/master/swagger
- No Lock In, BUT opinionated ( we cannot support every use case )
- Authentication
- Database
- Cache
- Web Framework
The objective is to allow for CRUD operations on the struct ( Create, Read, Update, Delete )
- GET ( Read, Singular and Multiple )
- POST ( Insert/Update )
- PUT ( Insert/Override )
- DELETE ( Delete )
There are a couple simple ways for one to use the project
go install github.com/team142/project-seedling/cmd/seedling@latest
//go:generate seedling -i user.go
Using if you provide your own templates
//go:generate seedling -template template
A More complex
//go:generate seedling -i user.go -version v1 -api fiber -s User,UserRole -o ../../
Example are in the example
folder