Coder Social home page Coder Social logo

twkun / auto-model Goto Github PK

View Code? Open in Web Editor NEW

This project forked from west3316/auto-model

0.0 0.0 0.0 19 KB

a tool, build golang struct model form mysql (mariadb)

Home Page: https://github.com/west3316/auto-model

License: MIT License

Go 93.00% Smarty 7.00%

auto-model's Introduction

auto-model

auto-model 是一款简单的数据表模型代码生成工具,支持从 mysql(或mariadb)数据表生成golang代码。

安装

git clone https://github.com/west3316/auto-model

cd auto-model

go build

快速开始

  1. 在数据库中建表
-- 示例表 user_charge
-- demo用到test数据库
ALTER DATABASE `test` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; 

CREATE TABLE `user_charge` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '唯一ID',
  `user_id` int(10) unsigned NOT NULL COMMENT '用户ID',
  `create_at` datetime NOT NULL COMMENT '充值时间',
  `value` decimal(20,2) NOT NULL COMMENT '充值金额',
  `result` enum('NoResult','Success','Fail','Locked') NOT NULL COMMENT '充值结果',
  `desc` text DEFAULT NULL COMMENT '备注',
  KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=640 DEFAULT CHARSET=utf8mb4
  1. 在config.toml中设置运行参数

  2. 运行生成命令

./auto-model.exe --config config.toml

示例生成代码 model/user_charge.go,也可以直接通过命令选项来,使用方法参看命令帮助 ./auto-model.exe --help

特点

支持enum枚举类型

auto-model's People

Contributors

west3316 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.