Example #1
0
// todo: check if this operation executes in app's root
func NewResource(name string) Resource {
	wd, _ := os.Getwd()
	splittedPath := strings.Split(wd, slash)

	return Resource{
		PluralTitle: inflect.Camelize(
			inflect.Pluralize(name),
		),
		SingularTitle: inflect.Camelize(
			inflect.Singularize(name),
		),
		PluralPath: inflect.Underscore(
			strings.ToLower(
				inflect.Pluralize(name),
			),
		),
		SingularPath: inflect.Underscore(
			strings.ToLower(
				inflect.Singularize(name),
			),
		),
		AppName: splittedPath[len(splittedPath)-1],
	}
}
Example #2
0
func getTableName(name string) string {
	if PluralizeTableNames {
		return inflect.Pluralize(snakeCasedName(name))
	}
	return snakeCasedName(name)
}