tableToStruct

command
v0.0.0-...-0c3ba03 Latest Latest
Warning

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

Go to latest
Published: May 26, 2015 License: Apache-2.0 Imports: 7 Imported by: 0

README

tableToStruct Code generator

$ tableToStruct
Usage of tableToStruct:
  -o="": Output file name
  -p="": Package name in template
  -prefixName="": Table name prefix
  -prefixSearch="eav": Search Table Prefix. Used in where condition to list tables
  -run=false: If true program runs

Install

Please don't. This program runs via go:generate.

Documentation

Overview

package main generates Go structs and slices from SQL tables.

Example

type (
    // TableStoreSlice contains pointers to TableStore types
    TableStoreSlice []*TableStore
    // TableStore a type for the MySQL table core_store
    TableStore struct {
        StoreID   int64          `db:"store_id"`   // store_id smallint(5) unsigned NOT NULL PRI  auto_increment
        Code      dbr.NullString `db:"code"`       // code varchar(32) NULL UNI
        WebsiteID int64          `db:"website_id"` // website_id smallint(5) unsigned NOT NULL MUL DEFAULT '0'
        GroupID   int64          `db:"group_id"`   // group_id smallint(5) unsigned NOT NULL MUL DEFAULT '0'
        Name      string         `db:"name"`       // name varchar(255) NOT NULL
        SortOrder int64          `db:"sort_order"` // sort_order smallint(5) unsigned NOT NULL  DEFAULT '0'
        IsActive  bool           `db:"is_active"`  // is_active smallint(5) unsigned NOT NULL MUL DEFAULT '0'
    }
)

and table structure collections:

	tableMap = csdb.TableStructureSlice{
		TableIndexStore: csdb.NewTableStructure(
			"core_store",
			[]string{
				"store_id",
			},
			[]string{

				"code",
				"website_id",
				"group_id",
				"name",
				"sort_order",
				"is_active",
			},
		),
    ...

Jump to

Keyboard shortcuts

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