Documentation ¶
Overview ¶
* Tencent is pleased to support the open source community by making 蓝鲸 available. * Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved. * Licensed under the MIT License (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * http://opensource.org/licenses/MIT * Unless required by applicable law or agreed to in writing, software distributed under * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language governing permissions and * limitations under the License.
* Tencent is pleased to support the open source community by making 蓝鲸 available. * Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved. * Licensed under the MIT License (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * http://opensource.org/licenses/MIT * Unless required by applicable law or agreed to in writing, software distributed under * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language governing permissions and * limitations under the License.
Index ¶
- func AddCommonFlags(cmdline *pflag.FlagSet) *bool
- func AddModelBizIDConditon(cond mapstr.MapStr, modelBizID int64)
- func ArrayUnique(a interface{}) (ret []interface{})
- func BoolArrayUnique(a []bool) (ret []bool)
- func BuildMongoField(key ...string) string
- func BuildMongoSyncItemField(key string) string
- func CCHeader(header http.Header) http.Header
- func CalSliceDiff(oldSlice, newSlice []string) (subs, plugs []string)
- func CalSliceInt64Diff(oldSlice, newSlice []int64) (subs, inter, plugs []int64)
- func CaseInsensitiveContains(s string, substr string) bool
- func CheckLen(sInput string, min, max int) bool
- func CloneHeader(src http.Header) http.Header
- func Contains(set []string, substr string) bool
- func ContainsAnyString(s string, subs ...string) bool
- func ContainsInt(set []int64, sub int64) bool
- func ContainsInt64(set []int64, sub int64) bool
- func ConvParamsTime(data interface{}) interface{}
- func ConverToInterfaceSlice(value interface{}) []interface{}
- func CopyHeader(src http.Header, target http.Header)
- func CopyMap(data map[string]interface{}, keys []string, ignores []string) map[string]interface{}
- func CountDuration(f func()) time.Duration
- func ExtractOwnerFromContext(ctx context.Context) string
- func ExtractRequestIDFromContext(ctx context.Context) string
- func ExtractRequestUserFromContext(ctx context.Context) string
- func FirstNotEmptyString(strs ...string) string
- func FormatPeriod(period string) (string, error)
- func GenerateRID() string
- func GetCurrentTimePtr() *time.Time
- func GetCurrentTimeStr() string
- func GetDailAddress(URL string) (string, error)
- func GetDefaultCCError(header http.Header) errors.DefaultCCErrorIf
- func GetFloat64ByInterface(a interface{}) (float64, error)
- func GetHTTPCCRequestID(header http.Header) string
- func GetInt64ByInterface(a interface{}) (int64, error)
- func GetIntByInterface(a interface{}) (int, error)
- func GetLanguage(header http.Header) string
- func GetMapInterfaceByInerface(data interface{}) ([]interface{}, error)
- func GetOwnerID(header http.Header) string
- func GetStrByInterface(a interface{}) string
- func GetStrValsFromArrMapInterfaceByKey(arrI []interface{}, key string) []string
- func GetUser(header http.Header) string
- func InArray(obj interface{}, target interface{}) bool
- func InStrArr(arr []string, key string) bool
- func InitFlags()
- func Int64Join(data []int64, separator string) string
- func IntArrIntersection(slice1 []int64, slice2 []int64) []int64
- func IntArrayUnique(a []int64) (ret []int64)
- func IsChar(sInput string) bool
- func IsDate(sInput string) bool
- func IsInnerObject(objID string) bool
- func IsNumChar(sInput string) bool
- func IsNumeric(val interface{}) bool
- func IsStrProperty(propertyType string) bool
- func IsTime(sInput string) bool
- func IsTimeZone(sInput string) bool
- func IsUser(sInput string) bool
- func MergeMaps(maps ...map[string]interface{}) map[string]interface{}
- func NewCloserWrapper(r io.Reader, closeFunc func() error) io.ReadCloser
- func NewContextFromGinContext(c *gin.Context) context.Context
- func NewContextFromHTTPHeader(header http.Header) context.Context
- func Normalize(str string) string
- func PeekRequest(req *http.Request) (content []byte, err error)
- func PrettyIPStr(ips []string) string
- func RemoveDuplicatesAndEmpty(slice []string) (ret []string)
- func SetModOwner(condition map[string]interface{}, ownerID string) map[string]interface{}
- func SetOwnerIDAndAccount(req *restful.Request)
- func SetQueryOwner(condition map[string]interface{}, ownerID string) map[string]interface{}
- func SliceInterfaceToBool(faceSlice []interface{}) ([]bool, error)
- func SliceInterfaceToInt64(faceSlice []interface{}) ([]int64, error)
- func SliceInterfaceToString(faceSlice []interface{}) ([]string, error)
- func SliceStrToInt(sliceStr []string) ([]int, error)
- func SliceStrToInt64(sliceStr []string) ([]int64, error)
- func SplitStrField(str, sep string) []string
- func Str2Time(timeStr string) time.Time
- func StrArrDiff(slice1 []string, slice2 []string) []string
- func StrArrayUnique(a []string) (ret []string)
- func ToMillisecond(d time.Duration) float64
- func ValidFieldTypeEnumOption(option interface{}, errProxy errors.DefaultCCErrorIf) error
- func ValidFieldTypeIntOption(option interface{}, errProxy errors.DefaultCCErrorIf) error
- func ValidFieldTypeListOption(option interface{}, errProxy errors.DefaultCCErrorIf) error
- func ValidPropertyOption(propertyType string, option interface{}, errProxy errors.DefaultCCErrorIf) error
- func WordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName
- type AtomicBool
- type Int64Slice
- type MapBuilder
- type Ticker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCommonFlags ¶
AddCommonFlags add common flags that is needed by all modules
func AddModelBizIDConditon ¶
AddModelBizIDConditon add model bizID condition according to bizID value
func ArrayUnique ¶
func ArrayUnique(a interface{}) (ret []interface{})
func BoolArrayUnique ¶
func BuildMongoField ¶
BuildMongoField build mongodb sub item field key
func BuildMongoSyncItemField ¶
BuildMongoSyncItemField build mongodb sub item synchronize field key
func CalSliceDiff ¶
func CalSliceInt64Diff ¶
func CaseInsensitiveContains ¶
func ContainsAnyString ¶
func ContainsInt64 ¶
ContainsInt64 if int64 target in array
func ConvParamsTime ¶
func ConvParamsTime(data interface{}) interface{}
func ConverToInterfaceSlice ¶
func ConverToInterfaceSlice(value interface{}) []interface{}
func CopyHeader ¶
CopyHeader copy http header into target
func CountDuration ¶
CountDuration count the duration of function f cost
func ExtractOwnerFromContext ¶
func FirstNotEmptyString ¶
FirstNotEmptyString return the first string in slice strs that is not empty
func FormatPeriod ¶
00002H --> 2H 0000D/0M ---> ∞ empty string / ∞ ---> ∞ regexp matched: positive integer (include positive integer begin with more the one '0') + D/H/M/S eg. 0H, 000H, 0002H, 32M,34S... examples of no matched: 1.4H, -2H, +2H ...
func GenerateRID ¶
func GenerateRID() string
func GetCurrentTimePtr ¶
func GetCurrentTimeStr ¶
func GetCurrentTimeStr() string
func GetDailAddress ¶
GetDailAddress returns the address for net.Dail
func GetDefaultCCError ¶
func GetDefaultCCError(header http.Header) errors.DefaultCCErrorIf
func GetFloat64ByInterface ¶
func GetHTTPCCRequestID ¶
GetHTTPCCRequestID return config center request id from http header
func GetInt64ByInterface ¶
func GetIntByInterface ¶
func GetLanguage ¶
func GetMapInterfaceByInerface ¶
func GetMapInterfaceByInerface(data interface{}) ([]interface{}, error)
func GetOwnerID ¶
func GetStrByInterface ¶
func GetStrByInterface(a interface{}) string
func GetStrValsFromArrMapInterfaceByKey ¶
GetStrValsFromArrMapInterfaceByKey get []string from []map[string]interface{}, Do not consider errors
func IntArrIntersection ¶
func IntArrayUnique ¶
IntArrayUnique get unique int array
func NewCloserWrapper ¶
func NewCloserWrapper(r io.Reader, closeFunc func() error) io.ReadCloser
func Normalize ¶
Normalize to trim space of the str and get it's upper format for example, Normalize(" hello world") ==> "HELLO WORLD"
func PrettyIPStr ¶
func SetModOwner ¶
SetModOwner set condition equal owner id, the condition must be a map or struct
func SetOwnerIDAndAccount ¶
func SetOwnerIDAndAccount(req *restful.Request)
set supplier id and account in head
func SetQueryOwner ¶
SetQueryOwner returns condition that in default ownerID and request ownerID
func SliceInterfaceToBool ¶
SliceInterfaceToBool将interface切片转化为bool切片,且interface的真实类型必须是bool. 失败则返回nil,error.
func SliceInterfaceToInt64 ¶
SliceInterfaceToInt64 将interface切片转化为int64切片,且interface的真实类型可以是任何整数类型. 失败则返回nil,error.
func SliceInterfaceToString ¶
SliceInterfaceToBool将interface切片转化为string切片,且interface的真实类型必须是string. 失败则返回nil,error.
func SliceStrToInt ¶
SliceStrToInt: 将字符串切片转换为整型切片
func SliceStrToInt64 ¶
SliceStrToInt64 将字符串切片转换为整型切片
func SplitStrField ¶
SplitStrField split string field, remove empty string
func StrArrDiff ¶
func StrArrayUnique ¶
StrArrayUnique get unique string array
func ToMillisecond ¶
func ValidFieldTypeEnumOption ¶
func ValidFieldTypeEnumOption(option interface{}, errProxy errors.DefaultCCErrorIf) error
func ValidFieldTypeIntOption ¶
func ValidFieldTypeIntOption(option interface{}, errProxy errors.DefaultCCErrorIf) error
func ValidFieldTypeListOption ¶
func ValidFieldTypeListOption(option interface{}, errProxy errors.DefaultCCErrorIf) error
func ValidPropertyOption ¶
func ValidPropertyOption(propertyType string, option interface{}, errProxy errors.DefaultCCErrorIf) error
ValidPropertyOption valid property field option
func WordSepNormalizeFunc ¶
func WordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName
WordSepNormalizeFunc changes all flags that contain "_" separators
Types ¶
type AtomicBool ¶
type AtomicBool int32
func NewBool ¶
func NewBool(yes bool) *AtomicBool
func (*AtomicBool) IsSet ¶
func (b *AtomicBool) IsSet() bool
func (*AtomicBool) Set ¶
func (b *AtomicBool) Set()
func (*AtomicBool) SetIfNotSet ¶
func (b *AtomicBool) SetIfNotSet() bool
func (*AtomicBool) SetTo ¶
func (b *AtomicBool) SetTo(yes bool)
func (*AtomicBool) UnSet ¶
func (b *AtomicBool) UnSet()
type Int64Slice ¶
type Int64Slice []int64
func (Int64Slice) Len ¶
func (p Int64Slice) Len() int
func (Int64Slice) Less ¶
func (p Int64Slice) Less(i, j int) bool
func (Int64Slice) Swap ¶
func (p Int64Slice) Swap(i, j int)
type MapBuilder ¶
type MapBuilder struct {
// contains filtered or unexported fields
}
func NewMapBuilder ¶
func NewMapBuilder(kvPairs ...interface{}) *MapBuilder
func (*MapBuilder) Append ¶
func (m *MapBuilder) Append(k string, vs ...interface{})
func (*MapBuilder) Build ¶
func (m *MapBuilder) Build() map[string]interface{}
func (*MapBuilder) Delete ¶
func (m *MapBuilder) Delete(k string)
func (*MapBuilder) Set ¶
func (m *MapBuilder) Set(k string, v interface{})