dmltogo

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package dmltogo A util can help to generate go struct by Create SQL DML. Input: create sql; Output: golang struct.

Example
package main

import (
	"log"

	"github.com/mnhkahn/togo/dmltogo"
)

func main() {
	res, err := dmltogo.DmlToGo(`CREATE TABLE Persons (
                     PersonID int,
                     LastName varchar(255),
                     FirstName varchar(255),
                     Address varchar(255),
                     City varchar(255) 
                 );`)
	log.Println(res, err)
	/*  res is:
	package model

	type Person struct {
		Address   string `gorm:"column:Address" json:"Address"`
		City      string `gorm:"column:City" json:"City"`
		FirstName string `gorm:"column:FirstName" json:"FirstName"`
		LastName  string `gorm:"column:LastName" json:"LastName"`
		PersonID  int    `gorm:"column:PersonID" json:"PersonID"`
	}

	// TableName sets the insert table name for this struct type
	func (p *Person) TableName() string {
		return "Persons"
	}
	*/
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DmlToGo

func DmlToGo(dml string) ([]byte, error)

DmlToGo uses create sql to generate golang struct with gorm tags.

Types

This section is empty.

Jump to

Keyboard shortcuts

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