Documentation ¶
Index ¶
- Constants
- Variables
- func Contains(items []string, item string) bool
- func DeepCopy(value interface{}) (interface{}, error)
- func DeepEqual(a, b map[string]interface{}) bool
- func Diff(a, b []string) (c, d, u []string)
- func FieldsIsExpected(fields, expected interface{}) bool
- func HandleCrash(slog *SLOG)
- func HttpRequest(client *http.Client, url, method, payload string, headers map[string]string) (int, []byte, error)
- func IsIpv6(ipstr string) bool
- func Keyname(s ...string) string
- func MD5(v []byte) string
- func MarshalJson(v interface{}) (map[string]interface{}, error)
- func MarshalNoEscaping(v interface{}) ([]byte, error)
- func NeedRetry(err error) bool
- func RequestIdFromContext(ctx context.Context) string
- func RetryErrorf(format string, v ...interface{}) error
- func SortIt(s *[]interface{}) []interface{}
- func Split(str string, size int) []string
- func ThisFuncName() string
- func TimeIt(slog *SLOG) func(format string, a ...interface{}) int64
- func TimeItToPrometheus() func()
- func TimeItTrace(slog *SLOG) func(format string, a ...interface{}) int64
- func TimeItWithLogFunc(lf func(format string, v ...interface{}), skip int) func(format string, a ...interface{}) int64
- func Unified(a []string) []string
- func UnmarshalJson(data interface{}, v interface{}) error
- type CtxKeyType
- type SLOG
- func (slog *SLOG) Debugf(format string, v ...interface{})
- func (slog *SLOG) Errorf(format string, v ...interface{})
- func (slog *SLOG) Infof(format string, v ...interface{})
- func (slog *SLOG) Tracef(format string, v ...interface{})
- func (slog *SLOG) Warnf(format string, v ...interface{})
- func (slog *SLOG) WithLevel(level string) *SLOG
- func (slog *SLOG) WithRequestID(reqid string) *SLOG
Constants ¶
View Source
const ( LogLevel_ERROR = 1 << iota LogLevel_WARN LogLevel_INFO LogLevel_DEBUG LogLevel_TRACE LogLevel_Type_TRACE = "trace" LogLevel_Type_DEBUG = "debug" LogLevel_Type_INFO = "info" LogLevel_Type_WARN = "warn" LogLevel_Type_ERROR = "error" )
Variables ¶
View Source
var ( FunctionDurationTimeCostTotal *prometheus.GaugeVec FunctionDurationTimeCostCount *prometheus.GaugeVec )
Functions ¶
func DeepCopy ¶
func DeepCopy(value interface{}) (interface{}, error)
performance: coping follow object 1000000 times cost: 2554 ms
sub := map[string]interface{}{ "suba": "string", "subb": 12345, "x": true, }
function:
a, e := DeepCopy(nil) a, e := DeepCopy([]string{"1", "2"}) a, e := DeepCopy(true) a, e := DeepCopy(123) a, e := DeepCopy(3.14) a, e := DeepCopy(map[string]interface{}{}) a, e := DeepCopy("123")
func FieldsIsExpected ¶
func FieldsIsExpected(fields, expected interface{}) bool
func HandleCrash ¶
func HandleCrash(slog *SLOG)
func HttpRequest ¶
func MarshalJson ¶
func MarshalNoEscaping ¶
func RequestIdFromContext ¶
func RetryErrorf ¶
func SortIt ¶
func SortIt(s *[]interface{}) []interface{}
TODO: test it with
A: []interface{}{ {"name": "customHTTPProfile"}, {"name": "customTCPProfile"}, }
B: []interface{}{ {"name": "customTCPProfile"}, {"name": "customHTTPProfile"}, }
reflect.DeepEqual(SortIt(A), SortIt(B)) == true
func ThisFuncName ¶
func ThisFuncName() string
func TimeItToPrometheus ¶
func TimeItToPrometheus() func()
func TimeItTrace ¶
func TimeItWithLogFunc ¶
func UnmarshalJson ¶
func UnmarshalJson(data interface{}, v interface{}) error
Types ¶
type CtxKeyType ¶
type CtxKeyType string
const ( CtxKey_RequestID CtxKeyType = "request_id" CtxKey_Logger CtxKeyType = "logger" )
type SLOG ¶
type SLOG struct { Level int // contains filtered or unexported fields }
func LogFromContext ¶
func (*SLOG) WithRequestID ¶
Click to show internal directories.
Click to hide internal directories.