goalesce

module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2024 License: Apache-2.0

README

Goalesce

goalesce is a command-line tool to generate OpenAPI CRUD routes from GORM models.

Features

  • Generate OpenAPI YAML files from GORM model types
  • Generate CRUD paths for each GORM model
  • Generate controllers, mappers, and repositories for each GORM model
  • goalesce uses oapi-codegen for generating server and controller interfaces

Install

$ go install github.com/joeriddles/goalesce/cmd/goalesce@latest

Usage

goalesce is largely configured using a YAML configuration file. Check out the GoDoc for Config for more detail.

Example:

# ./config.yaml
input_folder_path: ./model
output_file_path: ./generated
module_name: github.com/joeriddles/goalesce/examples/basic
models_package: github.com/joeriddles/goalesce/examples/basic/model
query_package: github.com/joeriddles/goalesce/examples/basic/query
clear_output_dir: true
// ./model/model.go
package model

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Name string `gorm:"column:name;"`
}
// ./main.go
package main

import (
	"github.com/joeriddles/goalesce/examples/basic/model"
	"gorm.io/gen"
)

func main() {
	g := gen.NewGenerator(gen.Config{
		OutPath: "query",
		Mode:    gen.WithoutContext | gen.WithQueryInterface,
	})
	g.ApplyBasic(model.User{})
	g.Execute()
}
# Run GORM gen
$ go run .
# Run Goalesce gen
$ goalesce -config config.yaml

Directories

Path Synopsis
cmd
goalesce command
examples
basic module
cars module
circular module
custom module
echo module
exclude module
pointers module
repository module
types module
yaml module
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL