templateutils

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: Apache-2.0 Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(in ...interface{}) (int64, error)

func Equal

func Equal(a, b reflect.Value) bool

Equal will check whether two value is equal.

func FuncMap

func FuncMap() template.FuncMap

FuncMap will return the template utils as FuncMap.

func In

func In(item reflect.Value, value reflect.Value) (bool, error)

In will check whether value is in item

func MakeSlice

func MakeSlice(item ...interface{}) []interface{}

MakeSlice will create a new slice via input values.

func SplitStringViaSpecialChars

func SplitStringViaSpecialChars(in string) []string

SplitStringViaSpecialChars will split strings via special chars.

Examples:

a_bc => [a, bc]
a-bc => [a, bc]
a bc => [a, bc]
a--b => [a, b]

func SplitStringViaUpperChars

func SplitStringViaUpperChars(in string) []string

SplitStringViaUpperChars will split string via upper case chars.

Examples:

abc => [abc]
Abc => [Abc]
AbC => [Ab, C]
AbCd => [Ab, Cd]
AAA => [AAA]
AAABb => [AAA, Bb]

All state: empty, upper, digit+lower All action: add, append

prev, cur, next, action empty, upper, empty, append empty, upper, upper, append empty, upper, lower, append upper, upper, empty, append upper, upper, upper, append upper, upper, lower, add lower, upper, empty, add lower, upper, upper, add lower, upper, lower, add empty, lower, empty, append empty, lower, upper, append empty, lower, lower, append upper, lower, empty, append upper, lower, upper, append upper, lower, lower, append lower, lower, empty, append lower, lower, upper, append lower, lower, lower, append

func ToCamel

func ToCamel(in string) string

ToCamel combines words by capitalizing all words following the first word and removing the space

func ToInt64

func ToInt64(x interface{}) (int64, error)

func ToKebab

func ToKebab(in string) string

ToKebab combines words by replacing each space with a dash (-)

func ToPascal

func ToPascal(in string) string

ToPascal combines words by capitalizing all words (even the first word) and removing the space

func ToSnack

func ToSnack(in string) string

ToSnack combines words by replacing each space with an underscore (_)

func ToUpperFirst

func ToUpperFirst(in string) string

ToUpperFirst will convert first letter to upper case.

func ZeroValue

func ZeroValue(in string) string

ZeroValue will return input type name's default zero value.

Types

type Field

type Field struct {
	Names []string
	Type  string
}

Field represent a field.

func (*Field) String

func (f *Field) String() string

type FieldList

type FieldList []*Field

FieldList is a list for Field.

func (FieldList) String

func (f FieldList) String() string

type Interface

type Interface struct {
	Name   string
	Method []*Method
}

Interface represent an interface.

type Method

type Method struct {
	Name    string
	Recv    *Recv
	Params  FieldList
	Results FieldList
}

Method represent a method.

type Recv

type Recv struct {
	Name string
	Type string
}

Recv represent a receiver

func (*Recv) String

func (r *Recv) String() string

type Source

type Source struct {
	Interfaces []*Interface
	Methods    []*Method
	// contains filtered or unexported fields
}

Source represent all content in the file.

func ParseContent

func ParseContent(filename string, content []byte) (s *Source, err error)

ParseContent will parse content.

Jump to

Keyboard shortcuts

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