SnippetsGO

package
v0.0.0-...-2f77c0e Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

关于Panic与recover的最佳实践

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPanic

func CheckPanic(err *error)

UT 把panic转换成error

func DoPanic

func DoPanic() (err error)

函数内使用了反射,会产生Panic

func FilterAccessId

func FilterAccessId(accessId string) bool

func GenTestArgs

func GenTestArgs() (int, error)

func MongoQueryMulti

func MongoQueryMulti(args MongoQueryMultiArgs) (rst interface{}, err error)

反射版本的创建数组、append

func NotifyFilterEntrence

func NotifyFilterEntrence(accessId string) error

入口

func Printf

func Printf(format string, a ...interface{}) (n int, err error)

Printf auto \n

func RemoveRepByMap

func RemoveRepByMap(slc []int) []int

List去重 通过map主键唯一的特性过滤重复元素

func ResetfInstance

func ResetfInstance()

func SliceToString

func SliceToString(x interface{}) string

use '_'

func StartRecover

func StartRecover()

func StringToSlice

func StringToSlice(ss string) []string

func TestSort

func TestSort()

Types

type IntSlice

type IntSlice []int32

func (*IntSlice) InSlice

func (ints *IntSlice) InSlice(v int32) bool

是否在列表里

type MongoQueryMultiArgs

type MongoQueryMultiArgs struct {
	DecodeType interface{} // the point of Decode Type
}

type NotifyFilter

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

func NewNotifyFilter

func NewNotifyFilter() *NotifyFilter

func (*NotifyFilter) IsRepeated

func (t *NotifyFilter) IsRepeated(in string) bool

true: Repeated

type StringSlice

type StringSlice []string

这个类型需要实现sort接口的Len,Less和Swap方法 | 这是官方包的例子

func (StringSlice) Len

func (x StringSlice) Len() int

func (StringSlice) Less

func (x StringSlice) Less(i, j int) bool

func (StringSlice) Swap

func (x StringSlice) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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