Skip to content

Latest commit

 

History

History
73 lines (48 loc) · 2.13 KB

README_CN.md

File metadata and controls

73 lines (48 loc) · 2.13 KB

GoDoc Codecov.io Go Report Card Mentioned in Awesome Go

godal

English | 中文

godal 提供了生成特定 Golang 代码的能力, 旨在提高研发编码的效率。

功能:

  1. 基于 Mysql 的建表语句快速生成对应 Golang 的 Model,可直接被 ORM 框架 GORM 使用。
  2. 待更新,欢迎大家提需求,会尽快适配。

godal 已经被加入到 awesome-go, MR link

使用教程

安装 godal

首先需要golang环境 See the install instructions for Go. See the go blog guide on using Go Modules.

git clone 后 进行 go install

git clone [email protected]:mafulong/godal.git
cd godal
go install

可以使用命令which godal 检验是否已安装

SQL 生成 Model

godal gen model --database {your databaseName} {your sqlFile}

例子

在本 repo 的 test 文件夹中有个测试 sql, 可以进行用来测试

godal gen model --database testdb gen_model.sql

What you can get?

example file1:

package testdb

import "time"

type TestTb1 struct {
	TestId         int       `gorm:"Column:test_id" json:"test_id"`
	TestTitle      string    `gorm:"Column:test_title" json:"test_title"`
	TestAuthor     string    `gorm:"Column:test_author" json:"test_author"`
	SubmissionDate time.Time `gorm:"Column:submission_date" json:"submission_date"`
}

func (TestTb1) TableName() string {
	return "test_tb1"
}

License

The MIT License (MIT). Please see License File for more information.