func newName(name string) names { return names{ Original: name, File: name, Table: inflect.Tableize(name), Proper: inflect.Camelize(name), Plural: inflect.Pluralize(inflect.Camelize(name)), Char: strings.ToLower(string([]byte(name)[0])), } }
// TableName returns the corresponding name of the underlying database table // for a given `Model`. See also `MapTableName` to change the default name of // the table. func (m *Model) TableName() string { if m.tableName != "" { return m.tableName } t := reflect.TypeOf(m.Value) name := m.typeName(t) defer tableMapMu.Unlock() tableMapMu.Lock() if tableMap[name] == "" { m.tableName = inflect.Tableize(name) tableMap[name] = m.tableName } return tableMap[name] }