util

package
v3.1.0-rc.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2018 License: MIT Imports: 20 Imported by: 0

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCommonFlags

func AddCommonFlags(cmdline *pflag.FlagSet) *bool

AddCommonFlags add common flags that is needed by all modules

func ArrayUnique

func ArrayUnique(a interface{}) (ret []interface{})

func CalSliceDiff

func CalSliceDiff(oldslice, newslice []string) (subs, plugs []string)

func CalSliceInt64Diff

func CalSliceInt64Diff(oldslice, newslice []int64) (subs, inter, plugs []int64)

func CheckLen

func CheckLen(sInput string, min, max int) bool

字符串输入长度

func Contains

func Contains(set []string, substr string) bool

Contains if string target in array

func ContainsInt

func ContainsInt(set []int64, sub int64) bool

ContainsInt if int target in array

func ContainsInt64

func ContainsInt64(set []int64, sub int64) bool

ContainsInt64 if int64 target in array

func ConvParamsTime

func ConvParamsTime(data interface{}) interface{}

func ConverToInterfaceSlice

func ConverToInterfaceSlice(value interface{}) []interface{}

func CopyHeader

func CopyHeader(src http.Header) http.Header

CopyHeader copy http header

func CopyMap

func CopyMap(data map[string]interface{}, keys []string, ignores []string) map[string]interface{}

func FileExists

func FileExists(name string) bool

func FirstNotEmptyString

func FirstNotEmptyString(strs ...string) string

FirstNotEmptyString return the first string in slice strs that is not empty

func GetActionLanguage

func GetActionLanguage(req *restful.Request) string

GetActionLanguage returns language form hender

func GetActionLanguageByHTTPHeader

func GetActionLanguageByHTTPHeader(header http.Header) string

GetActionLanguageByHTTPHeader return language from http header

func GetActionOnwerID

func GetActionOnwerID(req *restful.Request) string

GetActionOnwerID returns owner_uin form hender

func GetActionOnwerIDAndUser

func GetActionOnwerIDAndUser(req *restful.Request) (string, string)

GetActionOnwerIDAndUser returns owner_uin and user form hender

func GetActionOnwerIDByHTTPHeader

func GetActionOnwerIDByHTTPHeader(header http.Header) string

GetActionOnwerIDByHTTPHeader return owner from http header

func GetActionUser

func GetActionUser(req *restful.Request) string

GetActionUser returns user form hender

func GetCurrentTimeStr

func GetCurrentTimeStr() string

func GetDailAddress

func GetDailAddress(URL string) (string, error)

GetDailAddress returns the address for net.Dail

func GetHTTPCCRequestID

func GetHTTPCCRequestID(header http.Header) string

GetHTTPCCRequestID return configcenter request id from http header

func GetInt64ByInterface

func GetInt64ByInterface(a interface{}) (int64, error)

func GetIntByInterface

func GetIntByInterface(a interface{}) (int, error)

func GetLanguage

func GetLanguage(header http.Header) string

func GetMapInterfaceByInerface

func GetMapInterfaceByInerface(data interface{}) ([]interface{}, error)

func GetOwnerID

func GetOwnerID(header http.Header) string

func GetOwnerIDAndUser

func GetOwnerIDAndUser(header http.Header) (string, string)

func GetStrByInterface

func GetStrByInterface(a interface{}) string

func GetStrValsFromArrMapInterfaceByKey

func GetStrValsFromArrMapInterfaceByKey(arrI []interface{}, key string) []string

GetStrValsFromArrMapInterfaceByKey get []string from []map[string]interface{}, Do not consider errors

func GetUser

func GetUser(header http.Header) string

func InArray

func InArray(obj interface{}, target interface{}) bool

func InStrArr

func InStrArr(arr []string, key string) bool

func InitFlags

func InitFlags()

InitFlags normalizes and parses the command line flags

func IntArrIntersection

func IntArrIntersection(slice1 []int64, slice2 []int64) []int64

func IntArrayUnique

func IntArrayUnique(a []int64) (ret []int64)

IntArrayUnique get unique int array

func IsAssocateProperty

func IsAssocateProperty(propertyType string) bool

IsAssocateProperty is Assocate property

func IsChar

func IsChar(sInput string) bool

是否大、小写字母组合

func IsDate

func IsDate(sInput string) bool

是否日期

func IsInnerObject

func IsInnerObject(objID string) bool

IsInnerObject is inner object model

func IsNumChar

func IsNumChar(sInput string) bool

是否字母、数字组合

func IsStrProperty

func IsStrProperty(propertyType string) bool

IsStrProperty is string property

func IsTime

func IsTime(sInput string) bool

是否时间

func IsTimeZone

func IsTimeZone(sInput string) bool

是否时区

func MapMatch

func MapMatch(src, tar interface{}) bool

MapMatch return whether src is partial match to tar, means src is smaller than tar

func NewMapFromJSON

func NewMapFromJSON(data string) map[string]interface{}

func RemoveDuplicatesAndEmpty

func RemoveDuplicatesAndEmpty(slice []string) (ret []string)

func SetModOwner

func SetModOwner(condition interface{}, ownerID string) map[string]interface{}

SetModOwner set condition equal owner id, the condition must be a map or struct

func SetQueryOwner

func SetQueryOwner(condition interface{}, ownerID string) map[string]interface{}

SetQueryOwner returns condition that in default ownerid and request ownerid

func SliceStrToInt

func SliceStrToInt(sliceStr []string) ([]int, error)

SliceStrToInt: 将字符串切片转换为整型切片

func SliceStrToInt64

func SliceStrToInt64(sliceStr []string) ([]int64, error)

SliceStrToInt64 将字符串切片转换为整型切片

func Str2Time

func Str2Time(timeStr string) time.Time

str2time

func StrArrDiff

func StrArrDiff(slice1 []string, slice2 []string) []string

func StrArrayUnique

func StrArrayUnique(a []string) (ret []string)

StrArrayUnique get unique string array

func ValidPropertyOption

func ValidPropertyOption(propertyType string, option interface{}, errProxy errors.DefaultCCErrorIf) error

ValidPropertyOption valid property field option

func WarnWordSepNormalizeFunc

func WarnWordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName

WarnWordSepNormalizeFunc changes and warns for flags that contain "_" separators

func WordSepNormalizeFunc

func WordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName

WordSepNormalizeFunc changes all flags that contain "_" separators

Types

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 MapBuiler

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

func NewMapBuilder

func NewMapBuilder(kvpairs ...interface{}) *MapBuiler

func (*MapBuiler) Append

func (m *MapBuiler) Append(k string, vs ...interface{})

func (*MapBuiler) Build

func (m *MapBuiler) Build() map[string]interface{}

func (*MapBuiler) Delete

func (m *MapBuiler) Delete(k string)

func (*MapBuiler) Set

func (m *MapBuiler) Set(k string, v interface{})

type ParseInterface

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

ParseInterface parse interface use struct

func NewParseInterface

func NewParseInterface(data interface{}) *ParseInterface

NewParseInterface return a struct

func (*ParseInterface) ArrayInterface

func (p *ParseInterface) ArrayInterface() ([]interface{}, error)

ArrayInterface return interface val

func (*ParseInterface) Get

func (p *ParseInterface) Get(key string) *ParseInterface

Get get key from interface to ParseInterface

func (*ParseInterface) Interface

func (p *ParseInterface) Interface() (interface{}, error)

Interface return interface val

func (*ParseInterface) String

func (p *ParseInterface) String() (string, error)

String return string val

Jump to

Keyboard shortcuts

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