Documentation ¶
Index ¶
- Constants
- Variables
- func ArrayToString(arrays []string) string
- func CheckAndPrintError(flag string, err error)
- func EpochTime(time time.Time) string
- func EpochTimeNow() string
- func EpochToTime(epoch string) (time.Time, error)
- func FirstCaseToUpper(str string, first bool) string
- func FmtPrintln(info interface{})
- func GUID() string
- func HmacSha256Base64Signer(message string, secretKey string) (string, error)
- func IIIInterfaceOperator(condition bool, trueValue, falseValue interface{}) interface{}
- func InterfaceToInt(i interface{}) int
- func InterfaceToString(i interface{}) string
- func IsoTime(time time.Time) string
- func IsoTimeNow() string
- func IsoToTime(iso string) (time.Time, error)
- func JsonToStruct(jsonString string, object interface{})
- func Md5Signer(message string) string
- func Millisecond() int64
- func Nanosecond() int64
- func PreHashString(timestamp string, method string, requestPath string, body string) string
- func Print(arg ...interface{})
- func Println(arg ...interface{})
- func Second() int64
- func Stdout(arg ...interface{})
- func StringToTime(timeString string, layoutNo int) (time.Time, error)
- func StructToJson(object interface{}) string
- func TimeToString(time time.Time, layoutNo int) string
- func UTC() string
- func UUID() string
- type Info
- type InterfaceBuilder
- type String
- func (str *String) Append(arg *String) *String
- func (str *String) AppendFloat64(f float64) *String
- func (str *String) AppendInt(i int) *String
- func (str *String) AppendInt64(i int64) *String
- func (str *String) AppendString(arg string) *String
- func (str *String) Clear() *String
- func (str *String) Contains(chars string) bool
- func (str *String) ContainsIgnoreCase(chars string) bool
- func (str *String) EndsWith(s string) bool
- func (str *String) Index(chars string) int
- func (str *String) LastIndex(chars string) int
- func (str *String) Len() int
- func (str *String) Remove(index int) *String
- func (str *String) RemoveLast() *String
- func (str *String) Replace(old, new string) *String
- func (str *String) StartsWith(s string) bool
- func (str *String) Substring(beginIndex, endIndex int) *String
- func (str *String) SubstringBegin(beginIndex int) *String
- func (str *String) SubstringEnd(endIndex int) *String
- func (str *String) ToArray() []string
- func (str *String) ToFloat() (float64, error)
- func (str *String) ToInt() (int, error)
- func (str *String) ToInt64() (int64, error)
- func (str *String) ToLower() *String
- func (str *String) ToString() string
- func (str *String) ToUpper() *String
- func (str *String) Trim() *String
- type StringBuilder
- func (builder *StringBuilder) Append(s string) *StringBuilder
- func (builder *StringBuilder) AppendFloat64(f float64) *StringBuilder
- func (builder *StringBuilder) AppendInt(i int) *StringBuilder
- func (builder *StringBuilder) AppendInt64(i int64) *StringBuilder
- func (builder *StringBuilder) AppendStrings(ss ...string) *StringBuilder
- func (builder *StringBuilder) Clear() *StringBuilder
- func (builder *StringBuilder) RemoveLast() *StringBuilder
- func (builder *StringBuilder) Replace(old, new string) *StringBuilder
- func (builder *StringBuilder) ToString() string
Constants ¶
const ( DOT = "." COMMA = "," SEMICOLON = "" COLON = ":" AET = "@" HLINE = "-" UNDERLINE = "_" EMPTY = "" BRACKET_LEFT = "[" BRACKET_RIGHT = "]" BRACE_LEFT = "{" BRACE_RIGHT = "}" PARENTHESIS_LEFT = "(" PARENTHESIS_RIGHT = ")" SPRIT = "/" AND = "&" QUESTION = "?" EQUAL = "=" PROTOCOL = "://" HTTP = "http://" HTTPS = "https://" LF = "\n" CR = "\r" SPACE = " " )
const (
MILLION = 1000000
)
Variables ¶
var LAYOUT = map[int]string{
1: "2006-01-02",
2: "2006-01-02 15:04",
3: "2006-01-02 15:04:05",
4: "2006-01-02 15:04:05.001",
5: "2006-01-02T15:04:05.001Z",
6: "1136214245.001",
}
Functions ¶
func ArrayToString ¶
[9 9 8 4 2 9 1 7 - a 5 4 b - 3 3 1 6 - c d f 3 - 8 7 d 9 f b 5 7] -> "99842917-a54b-3316-cdf3-87d9fb57"
func CheckAndPrintError ¶
If there is an error print it, pass it
func EpochTimeNow ¶
func EpochTimeNow() string
func FirstCaseToUpper ¶
first = false: "aaa_bbb_ccc" -> "aaaBbbCcc" first = true: "aaa_bbb_ccc" -> "AaaBbbCcc"
func FmtPrintln ¶
func FmtPrintln(info interface{})
func HmacSha256Base64Signer ¶
signing a message using: hmac sha256 + base64
eg: message = Pre_hash function comment secretKey = E65791902180E9EF4510DB6A77F6EBAE return signed string = TO6uwdqz+31SIPkd4I+9NiZGmVH74dXi+Fd5X0EzzSQ=
func IIIInterfaceOperator ¶
func IIIInterfaceOperator(condition bool, trueValue, falseValue interface{}) interface{}
ternary operator, replace other language: a == b ? c : d
func InterfaceToInt ¶
func InterfaceToInt(i interface{}) int
func InterfaceToString ¶
func InterfaceToString(i interface{}) string
func IsoTimeNow ¶
func IsoTimeNow() string
func IsoToTime ¶
iso time change to time.Time eg: "2018-11-18T16:51:55.933Z" -> 2018-11-18 16:51:55.000000933 +0000 UTC
func JsonToStruct ¶
func JsonToStruct(jsonString string, object interface{})
Convert json string to struct eg: jsonString := "{\"field1\":\"Welcome to time space chain ...\",\"field2\":\"1688\",\"field3\":\"1314.521\"}" var info Info Json2Struct(jsonString, &info) println(info.Field1) print: Welcome to time space chain ...
func PreHashString ¶
the pre hash string
eg: timestamp = 2018-03-08T10:59:25.789Z method = POST request_path = /orders?before=2&limit=30 body = {"product_id":"BTC-USD-0309","order_id":"377454671037440"} return pre hash string = 2018-03-08T10:59:25.789ZPOST/orders?before=2&limit=30{"product_id":"BTC-USD-0309","order_id":"377454671037440"}
func StructToJson ¶
func StructToJson(object interface{}) string
*
Convert struct to json string eg: type Info struct { Field1 string `json:"field1"` Field2 int64 `json:"field2,string"` Field3 float64 `json:"field3,string"` } var info Info info.Field1 = "Welcome to time space chain ..." info.Field2 = 1688 info.Field3 = 1314.521 return: {"field1":"Welcome to time space chain ...","field2":"1688","field3":"1314.521"}
Types ¶
type Info ¶
type Info struct { Field1 string `json:"field1"` Field2 int64 `json:"field2,string"` Field3 float64 `json:"field3,string"` }
test struct
type InterfaceBuilder ¶
type InterfaceBuilder struct {
// contains filtered or unexported fields
}
func NewInterfaceBuilder ¶
func NewInterfaceBuilder() *InterfaceBuilder
func (*InterfaceBuilder) Append ¶
func (builder *InterfaceBuilder) Append(arg interface{}) *InterfaceBuilder
func (*InterfaceBuilder) Appends ¶
func (builder *InterfaceBuilder) Appends(args ...interface{}) *InterfaceBuilder
func (*InterfaceBuilder) Clear ¶
func (builder *InterfaceBuilder) Clear() *InterfaceBuilder
func (*InterfaceBuilder) ToInterfaces ¶
func (builder *InterfaceBuilder) ToInterfaces() []interface{}
type String ¶
type String struct {
// contains filtered or unexported fields
}
String struct. Usage: str1 := NewString("13990521234") str2 := NewString("14") str3 := str1.Substring(0, 2).Append(str2).AppendString("520") println(str1.ToString()) println(str2.ToString()) println(str3.ToString()) print: 13990521234 14 1314520
func NewStringFloat64 ¶
func NewStringInt ¶
func NewStringInt64 ¶
func (*String) AppendFloat64 ¶
func (*String) AppendInt64 ¶
func (*String) AppendString ¶
func (*String) Contains ¶
If a string contains a string, return true eg: "strings insert chars"
chars = "insert" -> true chars = "Insert" -> false chars = "key" -> false
func (*String) ContainsIgnoreCase ¶
If a string contains a string, return true, and ignore case. eg: "strings insert chars"
chars = "insert" -> true chars = "Insert" -> true chars = "key" -> false
func (*String) StartsWith ¶
"123xxxbbb5990" -> "123x" = true
func (*String) SubstringBegin ¶
str := NewString("abcde") str.SubstringBegin(2) return: "cde"
func (*String) SubstringEnd ¶
str := NewString("abcde") str.SubstringEnd(3) return: "abc"
type StringBuilder ¶
type StringBuilder struct {
// contains filtered or unexported fields
}
StringBuilder struct. Usage: builder := NewStringBuilder() builder.Append("a").Append("b").Append("c") s := builder.String() println(s) print: abc
func NewStringBuilder ¶
func NewStringBuilder() *StringBuilder
func NewStringBuilderString ¶
func NewStringBuilderString(str *String) *StringBuilder
func (*StringBuilder) Append ¶
func (builder *StringBuilder) Append(s string) *StringBuilder
func (*StringBuilder) AppendFloat64 ¶
func (builder *StringBuilder) AppendFloat64(f float64) *StringBuilder
func (*StringBuilder) AppendInt ¶
func (builder *StringBuilder) AppendInt(i int) *StringBuilder
func (*StringBuilder) AppendInt64 ¶
func (builder *StringBuilder) AppendInt64(i int64) *StringBuilder
func (*StringBuilder) AppendStrings ¶
func (builder *StringBuilder) AppendStrings(ss ...string) *StringBuilder
func (*StringBuilder) Clear ¶
func (builder *StringBuilder) Clear() *StringBuilder
func (*StringBuilder) RemoveLast ¶
func (builder *StringBuilder) RemoveLast() *StringBuilder
func (*StringBuilder) Replace ¶
func (builder *StringBuilder) Replace(old, new string) *StringBuilder
func (*StringBuilder) ToString ¶
func (builder *StringBuilder) ToString() string