ormtool

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2022 License: MIT Imports: 3 Imported by: 2

README

Convert database table to Golang struct

1. Get

go get github.com/enjoy322/ormtool@v1.2.0

2. Configuration

Note:The database field should be underlined in lowercase

// relative path
SavePath: "../../models/model.go",
// json tag
IsGenJsonTag: true,
// Generate one file or files
IsGenInOneFile: true,
// Generate simple database field information like: "int unsigned not null"
// value 1:not generate; 2:simple info
GenDBInfoType: 2,
// json tag type. The necessary conditions:IsGenJsonTag:true.
// 1.UserName 2.user_name 3.userName 4.user-name
JsonTagType: 3,
// sql of creating table in dateabase
IsGenCreateSQL: true,
// custom type relationships will be preferred
// the key is the database type, the value is the golang type
CustomType: map[string]string{
	"int":          "int",
	"int unsigned": "uint32",
	"tinyint(1)":   "bool",
	"json":         "json.RawMessage",
},

welcome pr和issue

Reference

https://github.com/gohouse/converter

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateMySQL

func GenerateMySQL(dbConf base.MysqlConfig, c base.Config)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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