utils

package
v0.0.0-...-aea69b8 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const HeaderComment = "// Code generated by https://github.com/nextzhou/goderive. DO NOT EDIT.\n\n"

Variables

This section is empty.

Functions

func Capitalize

func Capitalize(s string) string

func ExprTypeStr

func ExprTypeStr(expr ast.Expr) string

func IsBaseType

func IsBaseType(typ string) bool

func IsComparableSimpleType

func IsComparableSimpleType(typ string) bool

func IsComparableType

func IsComparableType(expr ast.Expr) bool

check if operator == is defined on this type

func IsExported

func IsExported(ident string) bool

func IsLocalPath

func IsLocalPath(path string) bool

func IsSelectorExpr

func IsSelectorExpr(expr string) bool

func IsSortableType

func IsSortableType(typ string) bool

func PkgNameFromPath

func PkgNameFromPath(path string) string

a/b/c.v5 => c

func SelectorExprString

func SelectorExprString(se *ast.SelectorExpr) string

func SplitSelectorExpr

func SplitSelectorExpr(expr string) (string, string)

time.Time => (time, Time)

func ToExported

func ToExported(ident string) string

func ToUnexported

func ToUnexported(ident string) string

func ValidateIdentName

func ValidateIdentName(name string) bool

Types

type ArgEmptyValueError

type ArgEmptyValueError struct {
	ArgKey string
}

func (*ArgEmptyValueError) Error

func (e *ArgEmptyValueError) Error() string

type ArgNotSingleValueError

type ArgNotSingleValueError struct {
	ArgKey string
}

func (*ArgNotSingleValueError) Error

func (e *ArgNotSingleValueError) Error() string

type ConflictingOptionError

type ConflictingOptionError struct {
	Type  string
	Ident string
}

func (*ConflictingOptionError) Error

func (e *ConflictingOptionError) Error() string

type DeriveComment

type DeriveComment struct {
	Plugin     string
	OptionsStr string
}

func MatchDeriveComment

func MatchDeriveComment(cmt string) (*DeriveComment, error)

func MatchPluginComment

func MatchPluginComment(cmt string) (*DeriveComment, error)

type InvalidIdentError

type InvalidIdentError struct {
	Type  string
	Ident string
}

func (*InvalidIdentError) Error

func (e *InvalidIdentError) Error() string

type NameWithPkg

type NameWithPkg struct {
	Name string
	Pkgs *StrSet
}

func FuncTypeNameWithPkg

func FuncTypeNameWithPkg(e ast.FuncType) *NameWithPkg

func NewNameWithPkg

func NewNameWithPkg(name string) *NameWithPkg

func TypeNameWithPkg

func TypeNameWithPkg(expr ast.Expr) *NameWithPkg

type NotExistedError

type NotExistedError struct {
	Type  string
	Ident string
}

func (*NotExistedError) Error

func (e *NotExistedError) Error() string

type OnlySupportError

type OnlySupportError struct {
	Supported string
	Got       string
}

func (*OnlySupportError) Error

func (e *OnlySupportError) Error() string

type Str

type Str = string

derive-set: Order=Append

type Str2

type Str2 = string

derive-set: Rename=StrOrderSet;Order=Key

type StrOrderSet

type StrOrderSet struct {
	// contains filtered or unexported fields
}

func NewAscendingStrOrderSet

func NewAscendingStrOrderSet(capacity int) *StrOrderSet

func NewAscendingStrOrderSetFromSlice

func NewAscendingStrOrderSetFromSlice(items []string) *StrOrderSet

func NewDescendingStrOrderSet

func NewDescendingStrOrderSet(capacity int) *StrOrderSet

func NewDescendingStrOrderSetFromSlice

func NewDescendingStrOrderSetFromSlice(items []string) *StrOrderSet

func NewStrOrderSet

func NewStrOrderSet(capacity int, cmp func(i, j string) bool) *StrOrderSet

func NewStrOrderSetFromSlice

func NewStrOrderSetFromSlice(items []string, cmp func(i, j string) bool) *StrOrderSet

func (*StrOrderSet) All

func (set *StrOrderSet) All(f func(string) bool) bool

func (*StrOrderSet) Any

func (set *StrOrderSet) Any(f func(string) bool) bool

func (*StrOrderSet) Append

func (set *StrOrderSet) Append(keys ...string)

func (*StrOrderSet) Clear

func (set *StrOrderSet) Clear()

func (*StrOrderSet) Clone

func (set *StrOrderSet) Clone() *StrOrderSet

func (*StrOrderSet) Contains

func (set *StrOrderSet) Contains(key string) bool

func (*StrOrderSet) ContainsAll

func (set *StrOrderSet) ContainsAll(keys ...string) bool

func (*StrOrderSet) ContainsAny

func (set *StrOrderSet) ContainsAny(keys ...string) bool

func (*StrOrderSet) CountBy

func (set *StrOrderSet) CountBy(f func(string) bool) int

func (*StrOrderSet) Difference

func (set *StrOrderSet) Difference(another *StrOrderSet) *StrOrderSet

func (*StrOrderSet) DoUntil

func (set *StrOrderSet) DoUntil(f func(string) bool) int

func (*StrOrderSet) DoUntilError

func (set *StrOrderSet) DoUntilError(f func(string) error) error

func (*StrOrderSet) DoWhile

func (set *StrOrderSet) DoWhile(f func(string) bool) int

func (*StrOrderSet) Equal

func (set *StrOrderSet) Equal(another *StrOrderSet) bool

func (*StrOrderSet) Filter

func (set *StrOrderSet) Filter(f func(string) bool) *StrOrderSet

func (*StrOrderSet) FilterMap

func (set *StrOrderSet) FilterMap(f interface{}) interface{}

f: func(string) *T

func(string) (T, bool)
func(string) (T, error)

return: []T

func (*StrOrderSet) FindBy

func (set *StrOrderSet) FindBy(f func(string) bool) *string

func (*StrOrderSet) FindLastBy

func (set *StrOrderSet) FindLastBy(f func(string) bool) *string

func (*StrOrderSet) Fold

func (set *StrOrderSet) Fold(init string, f func(string, string) string) string

func (*StrOrderSet) ForEach

func (set *StrOrderSet) ForEach(f func(string))

func (*StrOrderSet) ForEachWithIndex

func (set *StrOrderSet) ForEachWithIndex(f func(int, string))

func (*StrOrderSet) GroupBy

func (set *StrOrderSet) GroupBy(f func(string) interface{}) map[interface{}]*StrOrderSet

func (*StrOrderSet) GroupByBool

func (set *StrOrderSet) GroupByBool(f func(string) bool) (trueGroup *StrOrderSet, falseGroup *StrOrderSet)

func (*StrOrderSet) GroupByInt

func (set *StrOrderSet) GroupByInt(f func(string) int) map[int]*StrOrderSet

func (*StrOrderSet) GroupByStr

func (set *StrOrderSet) GroupByStr(f func(string) string) map[string]*StrOrderSet

func (*StrOrderSet) InPlaceUnion

func (set *StrOrderSet) InPlaceUnion(another *StrOrderSet)

func (*StrOrderSet) Intersect

func (set *StrOrderSet) Intersect(another *StrOrderSet) *StrOrderSet

func (*StrOrderSet) IsEmpty

func (set *StrOrderSet) IsEmpty() bool

func (*StrOrderSet) IsProperSubsetOf

func (set *StrOrderSet) IsProperSubsetOf(another *StrOrderSet) bool

func (*StrOrderSet) IsProperSupersetOf

func (set *StrOrderSet) IsProperSupersetOf(another *StrOrderSet) bool

func (*StrOrderSet) IsSubsetOf

func (set *StrOrderSet) IsSubsetOf(another *StrOrderSet) bool

func (*StrOrderSet) IsSupersetOf

func (set *StrOrderSet) IsSupersetOf(another *StrOrderSet) bool

func (*StrOrderSet) Len

func (set *StrOrderSet) Len() int

func (*StrOrderSet) Map

func (set *StrOrderSet) Map(f interface{}) interface{}

f: func(string) T return: []T

func (StrOrderSet) MarshalJSON

func (set StrOrderSet) MarshalJSON() ([]byte, error)

func (*StrOrderSet) Reduce

func (set *StrOrderSet) Reduce(f func(string, string) string) string

func (*StrOrderSet) Remove

func (set *StrOrderSet) Remove(key string)

func (*StrOrderSet) String

func (set *StrOrderSet) String() string

func (*StrOrderSet) ToSlice

func (set *StrOrderSet) ToSlice() []string

func (*StrOrderSet) ToSliceRef

func (set *StrOrderSet) ToSliceRef() []string

NOTICE: efficient but unsafe

func (*StrOrderSet) Union

func (set *StrOrderSet) Union(another *StrOrderSet) *StrOrderSet

func (*StrOrderSet) UnmarshalJSON

func (set *StrOrderSet) UnmarshalJSON(b []byte) error

type StrSet

type StrSet struct {
	// contains filtered or unexported fields
}

func NewStrSet

func NewStrSet(capacity int) *StrSet

func NewStrSetFromSlice

func NewStrSetFromSlice(items []string) *StrSet

func (*StrSet) All

func (set *StrSet) All(f func(string) bool) bool

func (*StrSet) Any

func (set *StrSet) Any(f func(string) bool) bool

func (*StrSet) Append

func (set *StrSet) Append(keys ...string)

func (*StrSet) Clear

func (set *StrSet) Clear()

func (*StrSet) Clone

func (set *StrSet) Clone() *StrSet

func (*StrSet) Contains

func (set *StrSet) Contains(key string) bool

func (*StrSet) ContainsAll

func (set *StrSet) ContainsAll(keys ...string) bool

func (*StrSet) ContainsAny

func (set *StrSet) ContainsAny(keys ...string) bool

func (*StrSet) CountBy

func (set *StrSet) CountBy(f func(string) bool) int

func (*StrSet) Difference

func (set *StrSet) Difference(another *StrSet) *StrSet

func (*StrSet) DoUntil

func (set *StrSet) DoUntil(f func(string) bool) int

func (*StrSet) DoUntilError

func (set *StrSet) DoUntilError(f func(string) error) error

func (*StrSet) DoWhile

func (set *StrSet) DoWhile(f func(string) bool) int

func (*StrSet) Equal

func (set *StrSet) Equal(another *StrSet) bool

func (*StrSet) Filter

func (set *StrSet) Filter(f func(string) bool) *StrSet

func (*StrSet) FilterMap

func (set *StrSet) FilterMap(f interface{}) interface{}

f: func(string) *T

func(string) (T, bool)
func(string) (T, error)

return: []T

func (*StrSet) FindBy

func (set *StrSet) FindBy(f func(string) bool) *string

func (*StrSet) FindLastBy

func (set *StrSet) FindLastBy(f func(string) bool) *string

func (*StrSet) Fold

func (set *StrSet) Fold(init string, f func(string, string) string) string

func (*StrSet) ForEach

func (set *StrSet) ForEach(f func(string))

func (*StrSet) ForEachWithIndex

func (set *StrSet) ForEachWithIndex(f func(int, string))

func (*StrSet) GroupBy

func (set *StrSet) GroupBy(f func(string) interface{}) map[interface{}]*StrSet

func (*StrSet) GroupByBool

func (set *StrSet) GroupByBool(f func(string) bool) (trueGroup *StrSet, falseGroup *StrSet)

func (*StrSet) GroupByInt

func (set *StrSet) GroupByInt(f func(string) int) map[int]*StrSet

func (*StrSet) GroupByStr

func (set *StrSet) GroupByStr(f func(string) string) map[string]*StrSet

func (*StrSet) InPlaceUnion

func (set *StrSet) InPlaceUnion(another *StrSet)

func (*StrSet) Intersect

func (set *StrSet) Intersect(another *StrSet) *StrSet

TODO keep order

func (*StrSet) IsEmpty

func (set *StrSet) IsEmpty() bool

func (*StrSet) IsProperSubsetOf

func (set *StrSet) IsProperSubsetOf(another *StrSet) bool

func (*StrSet) IsProperSupersetOf

func (set *StrSet) IsProperSupersetOf(another *StrSet) bool

func (*StrSet) IsSubsetOf

func (set *StrSet) IsSubsetOf(another *StrSet) bool

func (*StrSet) IsSupersetOf

func (set *StrSet) IsSupersetOf(another *StrSet) bool

func (*StrSet) Len

func (set *StrSet) Len() int

func (*StrSet) Map

func (set *StrSet) Map(f interface{}) interface{}

f: func(string) T return: []T

func (StrSet) MarshalJSON

func (set StrSet) MarshalJSON() ([]byte, error)

func (*StrSet) Reduce

func (set *StrSet) Reduce(f func(string, string) string) string

func (*StrSet) Remove

func (set *StrSet) Remove(key string)

func (*StrSet) String

func (set *StrSet) String() string

func (*StrSet) ToSlice

func (set *StrSet) ToSlice() []string

func (*StrSet) ToSliceRef

func (set *StrSet) ToSliceRef() []string

NOTICE: efficient but unsafe

func (*StrSet) Union

func (set *StrSet) Union(another *StrSet) *StrSet

func (*StrSet) UnmarshalJSON

func (set *StrSet) UnmarshalJSON(b []byte) error

type TableWriter

type TableWriter struct {
	// contains filtered or unexported fields
}

func NewTableWriter

func NewTableWriter(w io.Writer) *TableWriter

func (*TableWriter) Append

func (tw *TableWriter) Append(row []string)

func (*TableWriter) Render

func (tw *TableWriter) Render()

type TriBool

type TriBool uint8
const (
	TriBoolUndefined TriBool = 0
	TriBoolTrue      TriBool = 1
	TriBoolFalse     TriBool = 2
)

func BoolPtrToTri

func BoolPtrToTri(b *bool) TriBool

func BoolToTri

func BoolToTri(b bool) TriBool

func (TriBool) And

func (tb TriBool) And(another TriBool) TriBool

func (TriBool) IsFalse

func (tb TriBool) IsFalse() bool

func (TriBool) IsTrue

func (tb TriBool) IsTrue() bool

func (TriBool) IsUndefined

func (tb TriBool) IsUndefined() bool

func (TriBool) Not

func (tb TriBool) Not() TriBool

func (TriBool) Or

func (tb TriBool) Or(another TriBool) TriBool

func (TriBool) UnwrapOr

func (tb TriBool) UnwrapOr(b bool) bool

type UnexpectedError

type UnexpectedError struct {
	Type   string
	Idents []string
}

func (*UnexpectedError) Error

func (e *UnexpectedError) Error() string

type UnmatchedError

type UnmatchedError struct {
	Got      string
	Expected string
	Ident    string
}

func (*UnmatchedError) Error

func (e *UnmatchedError) Error() string

type UnsupportedError

type UnsupportedError struct {
	Type   string
	Idents []string
}

func (*UnsupportedError) Error

func (e *UnsupportedError) Error() string

Jump to

Keyboard shortcuts

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