format

package
v0.0.0-...-1039f8e Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2017 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Global name format functions

Index

Constants

This section is empty.

Variables

View Source
var (
	// struct name
	// return table name
	TableName = func(s string) string {
		return s
	}
	// field name, struct name, table name
	// if relation's struct name, primary key field name, table name and primary key column name
	// return column name
	ColumnName = func(a ...string) string {
		if len(a) == 3 {
			return a[0]
		} else {
			return a[3] + a[4]
		}
	}
	// field name, left struct name, left table name, right struct name, right table name
	// return many to many table name
	ManyToManyTableName = func(a ...string) string {
		if a[1] > a[3] {
			return a[3] + a[1]
		} else {
			return a[1] + a[3]
		}
	}
	// struct name, table name
	// return snapshot table name, id column name, time column name
	SnapshotName = func(s, t string) (string, string, string) {
		return "Snapshot" + s, "SnapshotId", "SnapshotTime"
	}
)

Functions

func CamelToUnderline

func CamelToUnderline(s string) string

ignore camel's underline, first upper not add underline

func UnderlineToCamel

func UnderlineToCamel(s string) string

more than one underline as one, first always upper

Types

This section is empty.

Jump to

Keyboard shortcuts

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