mcore

package module
v0.0.0-...-52c4d39 Latest Latest
Warning

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

Go to latest
Published: May 4, 2016 License: Apache-2.0 Imports: 25 Imported by: 10

README

mcore

Mabetle Go Core Lib

Documentation

Overview

mcore package wrap String ArrayList and etc.

Index

Examples

Constants

View Source
const (
	TRUE  = true
	FALSE = false
)
View Source
const (
	B_TRUE  = Bool(TRUE)
	B_FALSE = Bool(FALSE)
)
View Source
const (
	BAI      = 100
	QIAN     = 1000
	WAN      = 10000
	BAI_WAN  = 100 * 10000
	QIAN_WAN = 1000 * 10000
	YI       = 10000 * 10000
	WAN_YI   = 10000 * 10000 * 10000
)
View Source
const DefaultTimeFormat = "2006-01-02 15:04:05"
View Source
const (
	// NewLine .
	NewLine = byte(10)
)
View Source
const (
	UP_LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
)

Variables

View Source
var ErrInvalidNumber = errors.New("Invalid number format")
View Source
var (
	MonthArray []string = []string{"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
)
View Source
var O_NL = "\n"
View Source
var (
	WeekDayArray []string = []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
)

Functions

func Append

func Append(old []interface{}, value interface{}) []interface{}

Append append array

func AppendBefore

func AppendBefore(old []interface{}, value interface{}) (r []interface{})

AppendBefore append array

func AppendFile

func AppendFile(file string, appendContent string) (int, error)

AppendFile append file

func AppendFileBefore

func AppendFileBefore(file string, appendContent string) (int, error)

AppendFileBefore append file from beginning

func AppendFileByLocation

func AppendFileByLocation(file string, appendContent string, before bool) (int, error)

AppendFileByLocation append file by location

func CheckNullOrBlank

func CheckNullOrBlank(value interface{}, format string, args ...interface{}) bool

check value if null or blank

func CheckNullOrBlankWithErrMsg

func CheckNullOrBlankWithErrMsg(value interface{}, errMsg string) bool

func DirSubFiles

func DirSubFiles(dir string) ([]string, error)

DirSubFiles returns dir sub files.

func DirSubs

func DirSubs(dir string) ([]string, error)

DirSubs include dir and files

func EncodeGBK

func EncodeGBK(in string) string

EncodeGBK

func Expand

func Expand(v string) string

Expand expand env

func ExpandPath

func ExpandPath(path string) string

ExpandPath expand ~,%VAR%,$VAR,$(VAR),${VAR) to real path

func FormatFloat

func FormatFloat(v float64) string

FormateFloat cast float to formate string

func FormatTime

func FormatTime(t time.Time) string

FormatTime

func GetArgBool

func GetArgBool(name string, defaultValue bool, args ...string) bool

GetArgBool return bool value

func GetArgInt

func GetArgInt(name string, defaultValue int, args ...string) int

GetArgInt returns int value

func GetArgString

func GetArgString(name string, defaultValue string, args ...string) string

GetArgString arg format: a=b

func GetArrayFields

func GetArrayFields(m interface{}) []string

GetArrayFields m must be a array type.

func GetArrayFirstElement

func GetArrayFirstElement(rows interface{}) interface{}

GetArrayFirstElement return rows first row. rows must be a slice.

func GetConfigValue

func GetConfigValue(lines []string, key string, sep string) (string, error)

GetConfigValue returns config value from lines.

func GetCurrentDay

func GetCurrentDay() int

func GetCurrentMonth

func GetCurrentMonth() int

func GetCurrentYear

func GetCurrentYear() int

func GetDirSubFiles

func GetDirSubFiles(dir string) (fs []string)

GetPathFiles returns all file in dir

func GetElementType

func GetElementType(v interface{}) reflect.Type

GetElementType v should be a slicce.

func GetElementTypeName

func GetElementTypeName(v interface{}) string

GetElementTypeName values Type support struct, pointer, slice slice returns first element type.

func GetEnv

func GetEnv(name string) string

GetEnv returns env value

func GetFieldType

func GetFieldType(v interface{}, field string) reflect.Kind

GetFieldType return refelect.Kind, so can switch it.

func GetFieldValue

func GetFieldValue(v interface{}, field string) (r string)

GetFieldValue v can be struct or pointer.

func GetFieldValueOrigin

func GetFieldValueOrigin(v interface{}, field string) interface{}

GetFieldValueOrigin returns interface{}

func GetFields

func GetFields(m interface{}) (ns []string)

GetFields returns Fields Name Array, m could be pointer or struct. Emmber Struct call in rotate

func GetFieldsUsed

func GetFieldsUsed(fs []string, include, exclude string) (r []string)

GetFieldsUsed Order by Include if has include

func GetFieldsUsed2

func GetFieldsUsed2(fs []string, include, exclude string) (r []string)

GetFieldsUsed2 Order by fs

func GetFileConfigValue

func GetFileConfigValue(location string, key string, sep string) (string, error)

GetFileConfigValue returns config value from config files

func GetFileContent

func GetFileContent(file string) (string, error)

GetFileContent returns string from text file

func GetFileDir

func GetFileDir(location string) string

GetFileDir return file directory

func GetFileModifyTime

func GetFileModifyTime(file string) (int64, error)

GetFileModifyTime returns file modified time

func GetFileName

func GetFileName(path string) string

GetFileName returns path filename. path seperate with "/"

func GetFileSize

func GetFileSize(file string) (int64, error)

GetFileSize return files bytes

func GetFixedWidthNum

func GetFixedWidthNum(num int, width int) string

GetFixedWidthNum used for line number add space left side, align right

func GetFixedWidthString

func GetFixedWidthString(
	v string,
	width int,
	fil string,
	alignLeft bool) string

GetFixedWidthString

func GetFixedWidthStringAlignLeft

func GetFixedWidthStringAlignLeft(v string, width int) string

GetFixedWidthStringAlignLeft add blank to left used for pretty output.

func GetFixedWidthStringAlignRight

func GetFixedWidthStringAlignRight(v string, width int) string

GetFixedWidthStringAlignRight add blank right

func GetFlagString

func GetFlagString(name string) string

FIXME not work properly.

func GetLocation

func GetLocation(dir string, file string) string

GetLocation

func GetMapKeys

func GetMapKeys(m map[string]interface{}) (r []string)

func GetMappedName

func GetMappedName(name string, mapRules string) string

GetMappedName return mapped name with mapRules

func GetMethods

func GetMethods(v interface{}) (r []string)

GetMethods

func GetOS

func GetOS() string

func GetPackageNameFromDir

func GetPackageNameFromDir(dir string) string

dir such as abc/def or abc\\def for windows, return def

func GetParseArgs

func GetParseArgs(args ...string) []string

func GetPkgPath

func GetPkgPath(v interface{}) string

GetPkgPath

func GetRealPath

func GetRealPath(file string) string

GetRealPath returns file real path

func GetReflectFieldValue

func GetReflectFieldValue(v interface{}, fn string) reflect.Value

GetReflectFieldValue returns reflect.Value.

func GetReflectValue

func GetReflectValue(v interface{}) reflect.Value

GetReflectValue, returns reflect.Value, support both struct and pointer. if value is a pointer, indirect into it.

func GetString

func GetString(value interface{}) string

GetString

func GetSubFiles

func GetSubFiles(
	dir string,
	r bool,
	exts string,
	skipDirs string,
	skipFiles string,
) []string

GetSubFiles returns dir sub files exts: format .xx format. r: recursive

func GetSubFilesImpl

func GetSubFilesImpl(
	result *[]string,
	dir string,
	r bool,
	exts string,
	skipDirs string,
	skipFiles string,
) error

GetSubFilesImp returns sub files

func GetType

func GetType(v interface{}) reflect.Type

GetType returns value type. support struct and pointer both.

func GetTypeName

func GetTypeName(v interface{}) string

GetTypeName returns value type name.

func GetUsedArrayFields

func GetUsedArrayFields(m interface{}, include, exclude string) []string

GetUsedArrayFields

func GetUsedFields

func GetUsedFields(v interface{}, include, exclude string) (r []string)

GetUsedFields

func Home

func Home() string

Home returns user home path

func IsArgExists

func IsArgExists(name string, args ...string) bool

IsArgExists is exists arg

func IsChineseChar

func IsChineseChar(str string) bool

func IsDarwin

func IsDarwin() bool

FIXME not work in MacOS

func IsEnvExist

func IsEnvExist(name string) bool

IsEnvExist is env exists

func IsError

func IsError(v interface{}) (r bool)

IsError check error.

func IsException

func IsException(e Exception) bool

IsException is Exception

func IsExceptionType

func IsExceptionType(err error) bool

func IsFile

func IsFile(file string) bool

IsFile returns false when it's a directory or does not exist.

func IsFileExist

func IsFileExist(path string) bool

IsFileExist returns whether a file or directory exists.

func IsGitRepo

func IsGitRepo() bool

IsGitRepo reports whether the working directory is inside a Git repository.

func IsHasArg

func IsHasArg(arg string) bool

func IsHasDevArg

func IsHasDevArg() bool

func IsHasMethod

func IsHasMethod(v interface{}, methodName string) bool

IsHasMethod use GetMethods to judge.

func IsHasProdArg

func IsHasProdArg() bool

func IsHasTestArg

func IsHasTestArg() bool

func IsIncludeExcludeIn

func IsIncludeExcludeIn(field string, fields []string, include, exclude string) bool

IsIncludeExcludeIn

func IsLinux

func IsLinux() bool

FIXME not work in linux

func IsMapHasKey

func IsMapHasKey(m map[string]interface{}, key string) bool

func IsReturnHasError

func IsReturnHasError(args ...interface{}) (r bool)

IsReturnHasError check returns

func IsRuntimeException

func IsRuntimeException(e Exception) bool

IsRuntimeException is runtime Exception

func IsRuntimeExceptionType

func IsRuntimeExceptionType(err error) bool

IsRuntimeExceptionType is runtime Exception type

func IsUpLetter

func IsUpLetter(l string) bool

IsUpLetter

func IsValueEqual

func IsValueEqual(a, b interface{}) bool

IsValueEqual judge by string value

func IsWindows

func IsWindows() bool

func Join

func Join(sep string, args ...interface{}) string

Join joins args with sep

func JoinArgs

func JoinArgs(renderArgs map[string]interface{}, args ...string) []string

JoinArgs join args

func JoinArray

func JoinArray(sep string, args []interface{}) string

JoinArray joins array args with sep

func JoinPath

func JoinPath(paths ...string) string

JoinPath

func MakeDir

func MakeDir(dir string) error

MakeDir make dir

func MoveFile

func MoveFile(oldPath, newPath string) error

MoveFile move file if the newPath not exist, create one make sure move can success.

func NewCommand

func NewCommand(args []string) *exec.Cmd

NewCommand return new exec cmd args[0] cmd name args[1:] cmd args

func NewCommandFromString

func NewCommandFromString(cmd string) *exec.Cmd

NewCommandFromString create

func NewFileWriter

func NewFileWriter(location string) (io.Writer, error)

NewFileWriter file may not exist. if file not exist, create one.

func NewRandom

func NewRandom() int

NewRandom generate new random integer number.

Example
for i := 0; i < 100; i++ {
	println(i, ":", NewRandom())
}

println("======================================")

for i := 0; i < 100; i++ {
	println(i, ":", NewRangeRandom(1000000))
}
Output:

func NewRandomPassword

func NewRandomPassword() string

NewRandomPassword generate new number password.

func NewRangeRandom

func NewRangeRandom(n int) int

NewRangeRandom generate new random integer number range in 0~n

func Now

func Now() time.Time

func ParseStringToArgs

func ParseStringToArgs(s string) []string

ParseStringToArgs line to args FIXME not work as expect

func PrepareFile

func PrepareFile(location string) error

PrepareFile prepare file

func PrepareFileDir

func PrepareFileDir(file string) error

PrepareFileDir prepare file directory

func Print

func Print(v ...interface{})

print any type value

func PrintFile

func PrintFile(location string)

PrintFile

func PrintFile2

func PrintFile2(location string)

PrintFile2

func PrintFileWithLineNumber

func PrintFileWithLineNumber(file string)

PrintFileWithLineNumber

func PrintModel

func PrintModel(model interface{})

inpect model and print model should be a struct

func PrintModels

func PrintModels(models []interface{})

func PrintStringArray

func PrintStringArray(vs []string)

each item in array start a new line.

func PrintSubFiles

func PrintSubFiles(dir string, r bool, exts string)

PrintSubFiles exts format: .xxx,yyy

func PrintTime

func PrintTime(t time.Time)

PrintTime

func PrintType

func PrintType(v interface{})

PrintType pring value type

func Printf

func Printf(format string, v ...interface{})

func Println

func Println(v ...interface{})

after print, start a new line

func ProcessDir

func ProcessDir(dir string) string

ProcessDir process directory

func PutEnv

func PutEnv(name, value string) error

PutEnv puts env

func ReadArgs

func ReadArgs() []string

ReadArgs .

func ReadBool

func ReadBool(dft bool, msg ...interface{}) bool

ReadBool .

func ReadFileAll

func ReadFileAll(file string) (string, error)

ReadFileAll same to GetContent

func ReadFileLines

func ReadFileLines(file string) (lines []string, err error)

ReadLines

func ReadInt

func ReadInt(msg ...interface{}) int

ReadInt .

func ReadLine

func ReadLine() string

ReadLine from os.Stdio

func ReadLineWithMsg

func ReadLineWithMsg(msgs ...interface{}) string

ReadLineWithMsg .

func ReadNotBlankLine

func ReadNotBlankLine() (result string)

ReadNotBlankLine .

func ReadNotBlankLineWithMsg

func ReadNotBlankLineWithMsg(msgs ...interface{}) string

ReadNotBlankLineWithMsg .

func ReadNotZeroInt

func ReadNotZeroInt(msg ...interface{}) int

ReadNotZeroInt .

func ReadSelectArray

func ReadSelectArray(vs []string, msg ...interface{}) string

ReadSelectArray returns select array elements. vs should has elements

func ReadUrl

func ReadUrl(url string) ([]byte, error)

ReadUrl defautl read to []byte

func ReadUrlText

func ReadUrlText(url string) (string, error)

func RemoveFile

func RemoveFile(file string) error

RemoveFile delete file

func RenameFile

func RenameFile(file string, to string) error

RenameFile rename file name

func SetFieldValue

func SetFieldValue(v interface{}, field string, newValue interface{}) interface{}

SetFieldValue change struct field value. should use struct pointer.

func StrToFloat64

func StrToFloat64(v string) (r float64, err error)

StrToFloat64

func StrToInt

func StrToInt(v string) (r int, err error)

if cannot change, return 0

func StrToInt64

func StrToInt64(v string) (r int64, err error)

func StringLen

func StringLen(v string) int

StringLen how many chars

func StringWidth

func StringWidth(v string) int

StringWidth chinese char is width 2

func Sub

func Sub(str string, start, length int) string

Sub

func SubByByte

func SubByByte(str string, length int) string

SubByByte

func SubLeft

func SubLeft(s string, end int) string

SubLeft

func SubRight

func SubRight(s string, start int) string

SubRight

func ToCamel

func ToCamel(name string) string

ToCamel demo_demo > DemoDemo

func ToLabel

func ToLabel(name string) string

ToLabel returns space spilt string.

func ToTableName

func ToTableName(name string) string

ToTableName example: DemoTable to demo_table

func TouchFile

func TouchFile(file string) error

TouchFile touch file

func UpperCaseFirst

func UpperCaseFirst(in string) string

UpperCaseFirst

func WriteFile

func WriteFile(file string, content string) (n int, err error)

WriteFile put string to file

func WriteFileBytes

func WriteFileBytes(file string, v []byte) error

WriteFileBytes write file bytes

func WriteFileGBK

func WriteFileGBK(file, text string) (int, error)

WriteFileGBK write file

func WriteFileLines

func WriteFileLines(file string, lines []string) (int, error)

WriteFileLines write file lines

func WriteFileReader

func WriteFileReader(file string, r io.Reader) error

WriteFileReader write file header

func WriteFileWithError

func WriteFileWithError(location, content string, err error) error

WriteFileWithError get content from somewhere may be occur error when error is not nil, skip write

Types

type Any

type Any struct {
	Value interface{}
}

func NewAny

func NewAny(value interface{}) Any

func (Any) Float

func (v Any) Float() (float64, error)

func (Any) Int

func (v Any) Int() (i int64, err error)

func (Any) String

func (v Any) String() string

type Args

type Args []string

Args wraps args

func NewArgs

func NewArgs(args []string) Args

NewArgs creates Args

func NewArgsFromString

func NewArgsFromString(s string) Args

NewArgsFromString create Args

func (Args) IsHasFlag

func (a Args) IsHasFlag(flag string) bool

IsHasFlag returns is has flag

func (Args) NArgs

func (a Args) NArgs() int

NArgs number of args

func (Args) NFlags

func (a Args) NFlags() (r int)

NFlags number of flags

func (Args) ParseInt

func (a Args) ParseInt(flag string) (r int)

ParseInt parse int

func (Args) ParseString

func (a Args) ParseString(flag string) (r string)

ParseString parse string

func (Args) VArgs

func (a Args) VArgs(index int) string

VArgs value of args indexed

type ArrayList

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

ArrayList implements List interface.

func NewArrayList

func NewArrayList(model interface{}) *ArrayList

NewArrayList create a ArrayList instance. model

func (*ArrayList) IsContain

func (s *ArrayList) IsContain(value interface{}) bool

IsContain is contain value

func (*ArrayList) Len

func (s *ArrayList) Len() int

Len return length of value

func (*ArrayList) Next

func (s *ArrayList) Next() bool

Next for loop

func (*ArrayList) Print

func (s *ArrayList) Print()

Print out put

func (*ArrayList) Put

func (s *ArrayList) Put(values ...interface{})

Put put value

func (*ArrayList) Remove

func (s *ArrayList) Remove(value interface{})

Remove remove

func (*ArrayList) Type

func (s *ArrayList) Type() reflect.Type

Type return reflect type

func (*ArrayList) Value

func (s *ArrayList) Value() interface{}

Value returns cursor value

type Bool

type Bool bool

func (Bool) Format

func (b Bool) Format() string

type Byte

type Byte byte

type Bytes

type Bytes []byte

func (Bytes) AppendBool

func (bs Bytes) AppendBool(b bool) Bytes

func (Bytes) AppendQuote

func (bs Bytes) AppendQuote(s string) Bytes

func (Bytes) AppendQuoteRune

func (bs Bytes) AppendQuoteRune(r rune) Bytes

type Date

type Date struct {
	Year
	Month
	Day
}

func GetCurrentDate

func GetCurrentDate() Date

func NewDate

func NewDate(y, m, d int) (date Date)

func WrapDate

func WrapDate(t time.Time) Date

func (Date) String

func (d Date) String() string

type DateTime

type DateTime struct {
	Year
	Month
	Day
	Hour
	Minute
	Second
}

func GetCurrentDateTime

func GetCurrentDateTime() (dt DateTime)

func Parse

func Parse(layout, v string) (d DateTime, err error)

func ParseDefault

func ParseDefault(v string) (DateTime, error)

func WrapDateTime

func WrapDateTime(tm time.Time) (dt DateTime)

func (DateTime) Date

func (dt DateTime) Date() Date

func (DateTime) String

func (t DateTime) String() string

func (DateTime) Time

func (dt DateTime) Time() Time

type Day

type Day int

type Email

type Email string

func (Email) Validate

func (e Email) Validate() (b bool)

implement Validate

type Error

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

Error define Error

func NewErrError

func NewErrError(err error) *Error

NewErrError creates Error with error arg

func NewError

func NewError() *Error

NewError creates Error

func (*Error) Error

func (e *Error) Error() error

Erorr return Error error

func (*Error) Print

func (e *Error) Print()

Print print Error

func (*Error) PutError

func (e *Error) PutError(err error) *Error

PutError put error to Error

type ErrorType

type ErrorType int

ErrorType define

const (
	// TYPE_EXCEPTION define
	TYPE_EXCEPTION ErrorType = iota
	// TYPE_RUNTIME_EXCEPTION define
	TYPE_RUNTIME_EXCEPTION
)

type Errors

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

Errors record errors

func NewErrors

func NewErrors() *Errors

NewErrors creates new Errors

func (*Errors) Error

func (r *Errors) Error() error

Error return errors merged error message.

func (*Errors) HasError

func (r *Errors) HasError() bool

HasError check has errors

func (Errors) Len

func (r Errors) Len() int

Len return errors nums

func (*Errors) Print

func (r *Errors) Print()

Print prints errors

func (*Errors) Record

func (r *Errors) Record(err error)

Record records error

type Exception

type Exception struct {
	ErrorType
	// contains filtered or unexported fields
}

Exception app can not go on. app should check it.

func NewException

func NewException(err error) Exception

NewException create

func NewExceptionf

func NewExceptionf(format string, args ...interface{}) Exception

NewExceptionf create

func (Exception) Error

func (e Exception) Error() string

func (Exception) ErrorString

func (e Exception) ErrorString() string

ErrorString error string

type FileNotFoundError

type FileNotFoundError struct {
	RuntimeException
}

FileNotFoundError define

func NewFileNotFoundError

func NewFileNotFoundError(name string) FileNotFoundError

NewFileNotFoundError create

type Float32

type Float32 float32

type Float64

type Float64 float64

type Generater

type Generater interface {
	Generate()
}

type Hour

type Hour int

type Int

type Int int

func (Int) Itoa

func (t Int) Itoa() string

type Int32

type Int32 int32

type Int64

type Int64 int64

type KeyValue

type KeyValue struct {
	Key   string
	Value interface{}
}

func GetKeyValueArray

func GetKeyValueArray(lines []string, sep string) []KeyValue

GetKeyValueArray

func GetKeyValueArrayFromFile

func GetKeyValueArrayFromFile(location string, sep string) ([]KeyValue, error)

GetKeyValueArrayFromFile

func (KeyValue) Bool

func (kv KeyValue) Bool() bool

func (KeyValue) Float64

func (kv KeyValue) Float64(dv float64) float64

func (KeyValue) Int

func (kv KeyValue) Int(dv int) int

func (KeyValue) String

func (kv KeyValue) String() string

String

type KeyValueArray

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

func NewKeyValueArrayFromFile

func NewKeyValueArrayFromFile(location, sep string) (*KeyValueArray, error)

NewKeyValueArrayFromFile

func (*KeyValueArray) Bool

func (kva *KeyValueArray) Bool() bool

func (*KeyValueArray) Float64

func (kva *KeyValueArray) Float64(dv float64) float64

func (*KeyValueArray) Int

func (kva *KeyValueArray) Int(dv int) int

func (*KeyValueArray) IsContainKey

func (kva *KeyValueArray) IsContainKey(key string) bool

func (*KeyValueArray) Key

func (kva *KeyValueArray) Key() string

func (*KeyValueArray) KeyBool

func (kva *KeyValueArray) KeyBool(key string) bool

func (*KeyValueArray) KeyFloat64

func (kva *KeyValueArray) KeyFloat64(key string, dv float64) (float64, bool)

func (*KeyValueArray) KeyInt

func (kva *KeyValueArray) KeyInt(key string, dv int) (int, bool)

func (*KeyValueArray) KeyString

func (kva *KeyValueArray) KeyString(key string) (string, bool)

func (*KeyValueArray) Keys

func (kva *KeyValueArray) Keys() []string

func (*KeyValueArray) MoveTop

func (kva *KeyValueArray) MoveTop()

func (*KeyValueArray) Next

func (kva *KeyValueArray) Next() bool

func (*KeyValueArray) Put

func (kva *KeyValueArray) Put(key string, value interface{})

func (*KeyValueArray) String

func (kva *KeyValueArray) String() string

func (*KeyValueArray) Value

func (kva *KeyValueArray) Value() interface{}

type KeyValueMap

type KeyValueMap map[string]interface{}

func NewKeyValueMap

func NewKeyValueMap() KeyValueMap

func (KeyValueMap) GetKeys

func (c KeyValueMap) GetKeys() []string

func (KeyValueMap) IsHasKey

func (c KeyValueMap) IsHasKey(key string) bool

type List

type List interface {
	Next() bool
	Len() int
	Put(values ...interface{})
	Value() interface{}
}

List interface.

type Location

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

func NewLocation

func NewLocation(location string) (r Location)

func (Location) IsDir

func (t Location) IsDir() (r bool)

func (Location) Print

func (t Location) Print()

func (Location) ReadAll

func (t Location) ReadAll() (string, error)

func (Location) ReadLines

func (t Location) ReadLines() ([]string, error)

type Minute

type Minute int

type Money

type Money float64

func (Money) DivdeBai

func (m Money) DivdeBai() Money

func (Money) Divide

func (m Money) Divide(beDivided float64) Money

func (Money) DivideWan

func (m Money) DivideWan() Money

func (Money) DivideYi

func (m Money) DivideYi() Money

func (Money) Minus

func (m Money) Minus(to Money) Money

func (Money) Multiple

func (m Money) Multiple(beNum float64) Money

func (Money) MultipleBai

func (m Money) MultipleBai() Money

func (Money) MultipleWan

func (m Money) MultipleWan() Money

func (Money) MultipleYi

func (m Money) MultipleYi() Money

func (Money) Plus

func (m Money) Plus(to Money) Money

type Month

type Month int
const (
	M1 Month = 1 + iota
	M2
	M3
	M4
	M5
	M6
	M7
	M8
	M9
	M10
	M11
	M12
)
const (
	JAN Month = 1 + iota
	FEB
	MAR
	APR
	MAY
	JUN
	AUG
	SEP
	OCT
	NOV
	DEC
)

func (Month) String

func (t Month) String() string

type NumberFormatError

type NumberFormatError struct {
}

error

type OutRecorder

type OutRecorder struct {
	Writer io.Writer
	Type   string
}

func NewHtmlOutRecorder

func NewHtmlOutRecorder(w io.Writer) *OutRecorder

func NewOutRecorder

func NewOutRecorder(w io.Writer, typ string) *OutRecorder

func NewStdOutRecorder

func NewStdOutRecorder() *OutRecorder

func (*OutRecorder) Record

func (r *OutRecorder) Record(err error, okMsg string, args ...interface{})

func (*OutRecorder) RecordError

func (r *OutRecorder) RecordError(err error)

RecordError

func (*OutRecorder) RecordMsg

func (r *OutRecorder) RecordMsg(msg string, args ...interface{})

RecordMsg

func (*OutRecorder) Writef

func (r *OutRecorder) Writef(cssClass string, msg string, args ...interface{})

Writef

type Quarter

type Quarter int
const (
	Q1 Quarter = 1 + iota
	Q2
	Q3
	Q4
)

func GetCurrentQuarter

func GetCurrentQuarter() Quarter

func GetQuarter

func GetQuarter(month int) Quarter

type Results

type Results struct {
	Errors []error  //strore error
	Msgs   []string //store not error message.
}

Results define results

func NewResults

func NewResults() *Results

NewResults creates Results instanse.

func (*Results) IsHasError

func (r *Results) IsHasError() bool

IsHasError return has error or not

func (*Results) IsHasMsg

func (r *Results) IsHasMsg() bool

IsHasMsg returns has message or not.

func (*Results) Print

func (r *Results) Print()

Print prints errors and messages.

func (*Results) PrintErrors

func (r *Results) PrintErrors()

PrintErrors prints errors

func (*Results) PrintMsgs

func (r *Results) PrintMsgs()

PrintMsgs prints messages.

func (*Results) RecordError

func (r *Results) RecordError(err error)

RecordError records error

func (*Results) RecordErrorMsg

func (r *Results) RecordErrorMsg(errMsg ...interface{})

RecordErrorMsg record error message

func (*Results) RecordMsg

func (r *Results) RecordMsg(msg ...interface{})

RecordMsg records message

func (*Results) RecordfError

func (r *Results) RecordfError(format string, args ...interface{})

RecordfError record error with format.

func (*Results) RecordfMsg

func (r *Results) RecordfMsg(format string, args ...interface{})

RecordfMsg record message with format.

type Rune

type Rune rune

func (Rune) IsPrint

func (t Rune) IsPrint() bool

type RuntimeException

type RuntimeException struct {
	Exception
}

RuntimeException depends on apps, not check.

func NewRuntimeException

func NewRuntimeException(err error) RuntimeException

NewRuntimeException create

func NewRuntimeExceptionf

func NewRuntimeExceptionf(format string, args ...interface{}) RuntimeException

NewRuntimeExceptionf create

type Second

type Second int

type String

type String string

func NewString

func NewString(v interface{}) String

NewString

func (String) AddEnd

func (s String) AddEnd(end string) String

AddEnd

func (String) AddPrefix

func (s String) AddPrefix(pre string) String

AddPrefix

func (String) AddStart

func (s String) AddStart(start string) String

AddStart

func (String) AddSuffix

func (s String) AddSuffix(suf string) String

AddSuffix

func (String) Count

func (s String) Count(sep string) int

Count

func (String) Fields

func (s String) Fields() []string

Fields

func (String) Index

func (s String) Index(sep string) int

Index

func (String) IndexAny

func (s String) IndexAny(chars string) int

IndexAny

func (String) IndexByte

func (s String) IndexByte(c byte) int

IndexByte

func (String) IndexRune

func (s String) IndexRune(r rune) int

IndexRune

func (String) Int

func (s String) Int() int

Int trans String to int

func (String) IsBlank

func (s String) IsBlank() (r bool)

IsBlank if string is blank

func (String) IsChinese

func (in String) IsChinese() bool

func (String) IsContainIgnoreCase

func (s String) IsContainIgnoreCase(sub string) bool

IsContainIgnoreCase

func (String) IsContainInArray

func (s String) IsContainInArray(args []string) bool

IsContainInArray

func (String) IsContainInArrayIgnoreCase

func (s String) IsContainInArrayIgnoreCase(args []string) bool

IsContainInArrayIgnoreCase

func (String) IsContains

func (s String) IsContains(sub string) bool

IsContains

func (String) IsContainsAny

func (s String) IsContainsAny(chars string) bool

IsContainsAny

func (String) IsContainsInSepString

func (s String) IsContainsInSepString(arg string, sep string) bool

IsContainsInSepString

func (String) IsContainsInSepStringIgnoreCase

func (s String) IsContainsInSepStringIgnoreCase(arg string, sep string) bool

IsContainsInSepStringIgnoreCase

func (String) IsContainsRune

func (s String) IsContainsRune(r rune) bool

IsContainsRune

func (String) IsEmail

func (in String) IsEmail() bool

func (String) IsEndWith

func (s String) IsEndWith(end string) bool

IsEndWith equal to IsHasSuffix

func (String) IsEnglish

func (in String) IsEnglish() bool

func (String) IsEqualFold

func (s String) IsEqualFold(t string) bool

IsEqualFold

func (String) IsEqualIgnoreCase

func (s String) IsEqualIgnoreCase(v string) bool

IsEqualIgnoreCase

func (String) IsHasAny

func (s String) IsHasAny(chars string) (r bool)

IsHasAny is string include some string. equal to IsContains

func (String) IsHasPrefix

func (s String) IsHasPrefix(prefix string) bool

IsHasPrefix

func (String) IsHasSuffix

func (s String) IsHasSuffix(suffix string) bool

IsHasSuffix

func (String) IsIdCardNo

func (in String) IsIdCardNo() bool

func (String) IsIn

func (s String) IsIn(args ...string) bool

IsIn is in array

func (String) IsInArray

func (s String) IsInArray(args []string) bool

IsInArray Is In array

func (String) IsInArrayIgnoreCase

func (s String) IsInArrayIgnoreCase(args []string) bool

IsInArrayIgnoreCase

func (String) IsInIgnoreCase

func (s String) IsInIgnoreCase(args ...string) bool

IsInIgnoreCase is in array ignore case.

func (String) IsInSepString

func (s String) IsInSepString(arg string, sep string) bool

IsInSepString

func (String) IsInSepStringIgnoreCase

func (s String) IsInSepStringIgnoreCase(arg string, sep string) bool

IsInSepStringIgnoreCase

func (String) IsMatchString

func (in String) IsMatchString(exp string) bool

func (String) IsMustCompileMatch

func (in String) IsMustCompileMatch(pattern string) bool

func (String) IsNotBlank

func (s String) IsNotBlank() bool

IsNotBlank

func (String) IsNotIn

func (s String) IsNotIn(args ...string) bool

IsNotIn reverse for IsIn

func (String) IsNotInArray

func (s String) IsNotInArray(args []string) bool

IsNotInArray

func (String) IsNotInArrayIgnoreCase

func (s String) IsNotInArrayIgnoreCase(args []string) bool

IsNotInArrayIgnoreCase

func (String) IsNotInIgnoreCase

func (s String) IsNotInIgnoreCase(args ...string) bool

IsNotInIgnoreCase

func (String) IsNotInSepString

func (s String) IsNotInSepString(arg string, sep string) bool

IsNotInSepString

func (String) IsNotInSepStringIgnoreCase

func (s String) IsNotInSepStringIgnoreCase(arg, sep string) bool

IsNotInSepStringIgnoreCase

func (String) IsNumber

func (in String) IsNumber() bool

func (String) IsPhoneNumber

func (in String) IsPhoneNumber() bool

func (String) IsStartIgnoreCase

func (s String) IsStartIgnoreCase(prefix string) bool

IsStartIgnoreCase

func (String) IsStartInIgnoreCase

func (s String) IsStartInIgnoreCase(args []string) bool

IsStartInIgnoreCase

func (String) IsStartWith

func (s String) IsStartWith(start string) bool

IsStartWith equal to IsHasPrefix

func (String) IsStartsIgnoreCase

func (s String) IsStartsIgnoreCase(prefixs ...string) bool

IsStartsIgnoreCase

func (String) IsStartsIgnoreCaseInArray

func (s String) IsStartsIgnoreCaseInArray(prefixs []string) bool

IsStartsIgnoreCaseInArray

func (String) LastIndex

func (s String) LastIndex(sep string) int

LastIndex

func (String) LastIndexAny

func (s String) LastIndexAny(chars string) int

LastIndexAny

func (String) Len

func (s String) Len() int

Len

func (String) Quote

func (s String) Quote() string

func (String) QuoteToASCII

func (s String) QuoteToASCII() string

func (String) Repeat

func (s String) Repeat(count int) String

Repeat

func (String) Replace

func (s String) Replace(old, newStr string, n int) String

Replace

func (String) ReplaceAll

func (s String) ReplaceAll(old, newStr string) String

ReplaceAll

func (String) ReplaceAllNumber

func (s String) ReplaceAllNumber(newStr string) String

ReplaceAllNumber Replace all numbers

func (String) SepEnd

func (s String) SepEnd(sep string) (r String)

SepEnd "abc.go" SepEnd(".") return go.

func (String) SepStart

func (s String) SepStart(sep string) (r String)

SepStart abc.go return abc

func (String) Split

func (s String) Split(sep string) []string

Split

func (String) String

func (s String) String() string

String

func (String) Sub

func (s String) Sub(start, length int) String

Sub string

func (String) SubLeft

func (s String) SubLeft(length int) String

SubLeft

func (String) SubLeftSep

func (s String) SubLeftSep(sep string) string

SubLeftSep

func (String) SubRight

func (s String) SubRight(length int) String

SubRight

func (String) SubRightSep

func (s String) SubRightSep(sep string) string

SubRightSep

func (String) Title

func (s String) Title() String

Title

func (String) ToBool

func (s String) ToBool() bool

bool pairs: 1/0 YES/NO TRUE/FALSE ON/OFF

func (String) ToBytes

func (s String) ToBytes() []byte

func (String) ToExcelTime

func (s String) ToExcelTime() time.Time

ToExcelTime string format: int64 days after 1900.01.01 FIXME not work properly

func (String) ToExcelTimeString

func (s String) ToExcelTimeString() string

func (String) ToFloat

func (s String) ToFloat(bitSize int) (float64, error)

func (String) ToFloat32

func (s String) ToFloat32() (float32, error)

func (String) ToFloat32NoError

func (s String) ToFloat32NoError() float32

func (String) ToFloat64

func (s String) ToFloat64() (float64, error)

ToFloat64

func (String) ToFloat64NoError

func (s String) ToFloat64NoError() float64

ToFloat64NoError

func (String) ToInt

func (s String) ToInt() (int, error)

func (String) ToIntNoError

func (s String) ToIntNoError() int

func (String) ToLower

func (s String) ToLower() String

ToLower

func (String) ToTime

func (s String) ToTime() (time.Time, error)

ToTime string format: 1999-01-01 00:00:00

func (String) ToUpper

func (s String) ToUpper() String

ToUpper

func (String) Trim

func (s String) Trim(cutset string) String

Trim

func (String) TrimBeginIndex

func (s String) TrimBeginIndex(sep string) String

TrimBeginIndex

func (String) TrimEnd

func (s String) TrimEnd(end string) String

TrimEnd equal to TrimRight

func (String) TrimEndIndex

func (s String) TrimEndIndex(sep string) String

TrimEndIndex eg: "a/b/c" TrimEndIndex("/") returns a/b

func (String) TrimEnds

func (s String) TrimEnds(ends ...string) String

TrimEnds

func (String) TrimLeft

func (s String) TrimLeft(cutset string) String

TrimLeft

func (String) TrimPrefix

func (s String) TrimPrefix(prefix string) String

TrimPrefix

func (String) TrimQuotes

func (s String) TrimQuotes() String

TrimQuotes "abc" to abc

func (String) TrimRight

func (s String) TrimRight(cutset string) String

TrimRight

func (String) TrimSpace

func (s String) TrimSpace() String

TrimSpace

func (String) TrimStart

func (s String) TrimStart(start string) String

TrimStart equal to TrimLeft

func (String) TrimStarts

func (s String) TrimStarts(starts ...string) String

TrimStarts

func (String) TrimSuffix

func (s String) TrimSuffix(suffix string) String

TrimSuffix

func (String) Unquote

func (s String) Unquote() (string, error)

func (String) Value

func (s String) Value() string

Value equal to String()

type StringArray

type StringArray []string

func NewStringArray

func NewStringArray(items ...string) StringArray

func (StringArray) AppendStringArray

func (s StringArray) AppendStringArray(a StringArray) StringArray

func (StringArray) Join

func (s StringArray) Join(sep string) string

func (StringArray) Merge

func (s StringArray) Merge() string

new line one item

func (StringArray) MergeWithOsNewLine

func (s StringArray) MergeWithOsNewLine() string

MergeWithOsNewLine

func (StringArray) RemoveBlank

func (s StringArray) RemoveBlank() (r StringArray)

func (StringArray) RemoveBlankAndComment

func (s StringArray) RemoveBlankAndComment(start string) StringArray

func (StringArray) RemoveBlankAndSharpComment

func (s StringArray) RemoveBlankAndSharpComment() StringArray

func (StringArray) RemoveBlankAndSlashComment

func (s StringArray) RemoveBlankAndSlashComment() StringArray

func (StringArray) RemoveComment

func (s StringArray) RemoveComment(start string) (r StringArray)

func (StringArray) RemoveSharpComment

func (s StringArray) RemoveSharpComment() StringArray

func (StringArray) RemoveSlashComment

func (s StringArray) RemoveSlashComment() StringArray

func (StringArray) RoundJoin

func (s StringArray) RoundJoin(round, sep string) string

example: {"a", "b" , "c"} to "a,b,c"

type StringBuffer

type StringBuffer struct {
	*bytes.Buffer
}

StringBuffer ideas from java StringBuffer.

func NewStringBuffer

func NewStringBuffer(v ...interface{}) (sb StringBuffer)

NewStringBuffer create no args.

func (StringBuffer) Append

func (sb StringBuffer) Append(args ...interface{})

Append append

func (StringBuffer) AppendArrayCSVLine

func (sb StringBuffer) AppendArrayCSVLine(values []string)

AppendArrayCSVLine append "[a,b,c] as a,b,c\n"

func (StringBuffer) AppendByteArray

func (sb StringBuffer) AppendByteArray(bs []byte)

AppendByteArray append

func (StringBuffer) AppendEachLine

func (sb StringBuffer) AppendEachLine(lines ...interface{})

AppendEachLine append line by line

func (StringBuffer) AppendLine

func (sb StringBuffer) AppendLine(args ...interface{})

AppendLine append line

func (StringBuffer) AppendLinef

func (sb StringBuffer) AppendLinef(format string, args ...interface{})

AppendLinef append line with format

func (StringBuffer) AppendLines

func (sb StringBuffer) AppendLines(lines []string)

AppendLines append lines

func (StringBuffer) Appendf

func (sb StringBuffer) Appendf(format string, args ...interface{})

Appendf appends with format

func (StringBuffer) Clear

func (sb StringBuffer) Clear()

Clear clear value

func (StringBuffer) HTML

func (sb StringBuffer) HTML() template.HTML

HTML returns html template.HTML

func (StringBuffer) Print

func (sb StringBuffer) Print()

Print StringBuffer content to stdout.

func (StringBuffer) String

func (sb StringBuffer) String() string

String return string

func (StringBuffer) WriteTo

func (sb StringBuffer) WriteTo(dest io.Writer) (int64, error)

WriteTo write

func (StringBuffer) WriteToFile

func (sb StringBuffer) WriteToFile(file string) (int64, error)

WriteToFile write to file

type StringKeyValueMap

type StringKeyValueMap map[string]string

func NewStringKeyValueMap

func NewStringKeyValueMap() StringKeyValueMap

func (StringKeyValueMap) GetBool

func (c StringKeyValueMap) GetBool(key string) bool

func (StringKeyValueMap) GetInt

func (c StringKeyValueMap) GetInt(key string) int

func (StringKeyValueMap) GetString

func (c StringKeyValueMap) GetString(key string) string

func (StringKeyValueMap) GetStringWithDefault

func (c StringKeyValueMap) GetStringWithDefault(key, defaultValue string) string

func (StringKeyValueMap) IsContain

func (c StringKeyValueMap) IsContain(key string) bool

func (StringKeyValueMap) Put

func (c StringKeyValueMap) Put(key, value string)

put key value

type Time

type Time struct {
	Hour
	Minute
	Second
}

func GetCurrentTime

func GetCurrentTime() Time

func NewTime

func NewTime(h, m, s int) (t Time)

func WrapTime

func WrapTime(tm time.Time) (t Time)

func (Time) String

func (t Time) String() string

type Validetor

type Validetor interface {
	Validate(v interface{}) bool
}

Validator

type Week

type Week int

func GetCurrentWeek

func GetCurrentWeek() Week

type WeekDay

type WeekDay int
const (
	SUN WeekDay = iota
	MON
	TUE
	WED
	THU
	FRI
	SAT
)

func GetCurrentWeekDay

func GetCurrentWeekDay() WeekDay

func (WeekDay) String

func (t WeekDay) String() string

type WrapArgs

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

WrapArgs wrap renderArgs and args together

func NewWrapArgs

func NewWrapArgs(renderArgs map[string]interface{}, args ...string) *WrapArgs

NewWrapArgs creates instance

func (*WrapArgs) GetArgBool

func (a *WrapArgs) GetArgBool(name string, dv bool) bool

GetArgBool

func (*WrapArgs) GetArgFloat64

func (a *WrapArgs) GetArgFloat64(name string, dv float64) float64

GetArgFloat64 returns Float64

func (*WrapArgs) GetArgInt

func (a *WrapArgs) GetArgInt(name string, dv int) int

GetArgInt returns int

func (*WrapArgs) GetArgString

func (a *WrapArgs) GetArgString(name string, dv string) string

GetArgString returns name string value

func (*WrapArgs) IsArgExists

func (a *WrapArgs) IsArgExists(name string) bool

IsArgExists returns name exists or not

type Year

type Year int

type YearDay

type YearDay int

func GetCurrentYearDay

func GetCurrentYearDay() YearDay

Directories

Path Synopsis
package mcmd.
package mcmd.
mabetle config package.
mabetle config package.
ini
xml
mabetle math functions.
mabetle math functions.
its very interesting and simple for go main file to run all kinds funcs and runable struct.
its very interesting and simple for go main file to run all kinds funcs and runable struct.
sdb define some APIs SimpleTable a csv(or tsv), sheet, database table can abstract to SimpleTable the ideas from jdbc API Next() for loop, and holder a rowIndex RandomAccessTable There is no rowIndex concept, but you can walk rows too with loop.
sdb define some APIs SimpleTable a csv(or tsv), sheet, database table can abstract to SimpleTable the ideas from jdbc API Next() for loop, and holder a rowIndex RandomAccessTable There is no rowIndex concept, but you can walk rows too with loop.
Mabetle Stat Package.
Mabetle Stat Package.
Provide AssertEqual, AssertTrue, AssertFalse for test.
Provide AssertEqual, AssertTrue, AssertFalse for test.

Jump to

Keyboard shortcuts

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