gormsql

module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2019 License: MIT

README

gormsql

Go Report Card

Generating of the models for gorm from sql

Usage

Create sql expression for make new table

CREATE TABLE IF NOT EXISTS app_user (

  id int NOT NULL,
  username varchar(45) NOT NULL,  
  password varchar(450) NOT NULL,  
  enabled integer NOT NULL DEFAULT '1',
  created_at timestamp, 
  points float,
  small bigint,
  PRIMARY KEY (id)  
);

Apply generation

go run gormsql.go --dir out app.sql

After generation it'll create new file at the out dir


package out
type App_user struct { Enabled int "`gorm:`NOT NULL;DEFAULT:`1``"; Created_at time.Time; Points float64; Small int64; Id int "`gorm:`NOT NULL;PRIMARY_KEY;`"; Username string "`gorm:`NOT NULL;`"; Password string "`gorm:`NOT NULL;`" }

Directories

Path Synopsis
cmd
gormsql command
pkg
core
Package core defines main logic
Package core defines main logic
os
Package os implements io operations with files
Package os implements io operations with files
sqlparser
Package sqlparser provides parsing of the input sql queries
Package sqlparser provides parsing of the input sql queries

Jump to

Keyboard shortcuts

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