utils

package
v10.3.5 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FuncMap = template.FuncMap{
	"lower":              strings.ToLower,
	"upper":              strings.ToUpper,
	"title":              strings.ToTitle,
	"lowerUnderline":     ToLowerUnderlinedNamer,
	"plural":             ToPlural,
	"lowerPlural":        ToLowerPlural,
	"lowerSpacePlural":   ToLowerSpacePlural,
	"lowerHyphensPlural": ToLowerHyphensPlural,
	"lowerCamel":         ToLowerCamel,
	"lowerSpace":         ToLowerSpacedNamer,
	"titleSpace":         ToTitleSpaceNamer,
	"convIfCond":         tplConvToIfCond,
	"convSwaggerType":    tplConvToSwaggerType,
	"raw":                func(s string) template.HTML { return template.HTML(s) },
	"convGoTypeToTsType": func(goType string) string {
		if strings.Contains(goType, "int") || strings.Contains(goType, "float") {
			return "number"
		} else if goType == "bool" {
			return "boolean"
		}
		return "string"
	},
}

FuncMap is a map of functions that can be used in templates.

Functions

func ExecGitClone

func ExecGitClone(dir, url, branch, name string) error

func ExecGitInit

func ExecGitInit(dir string) error

func ExecGoFormat

func ExecGoFormat(name string) error

Formats the given Go source code file

func ExecGoImports

func ExecGoImports(dir, name string) error

Executes the goimports command on the given file

func ExecGoInstall

func ExecGoInstall(dir, path string) error

func ExecGoModTidy

func ExecGoModTidy(dir string) error

func ExecSwagGen

func ExecSwagGen(dir, generalInfo, output string) error

Executes the swag command on the given file

func ExecTree

func ExecTree(dir string) error

func ExecWireGen

func ExecWireGen(dir, path string) error

Executes the wire command on the given file

func ExistsFile

func ExistsFile(name string) (bool, error)

ExistsFile checks if the given file exists

func GetDefaultProjectTree

func GetDefaultProjectTree() string

func IsDir

func IsDir(name string) bool

Checks if the given path is a directory

func ParseJSONFile

func ParseJSONFile(name string, obj interface{}) error

Parses the given JSON file

func ParseYAMLFile

func ParseYAMLFile(name string, obj interface{}) error

Parses the given YAML file

func ReplaceFileContent

func ReplaceFileContent(file string, old, new []byte, m fs.FileMode) error

func Scanner

func Scanner(r io.Reader, fn func(string) string) *bytes.Buffer

Scanner scans the given reader line by line and calls the given function

func ToLowerCamel

func ToLowerCamel(v string) string

func ToLowerHyphensPlural

func ToLowerHyphensPlural(v string) string

func ToLowerPlural

func ToLowerPlural(v string) string

func ToLowerSpacePlural

func ToLowerSpacePlural(v string) string

func ToLowerSpacedNamer

func ToLowerSpacedNamer(v string) string

func ToLowerUnderlinedNamer

func ToLowerUnderlinedNamer(name string) string

func ToPlural

func ToPlural(v string) string

func ToTitleSpaceNamer

func ToTitleSpaceNamer(v string) string

func WriteFile

func WriteFile(name string, data []byte) error

WriteFile writes the given data to the given file

Types

This section is empty.

Jump to

Keyboard shortcuts

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