Documentation ¶
Index ¶
- Constants
- func AlreadyTimeStr(t2 time.Time, timezone ...*time.Location) string
- func Camel2Case(name string) string
- func Case2Camel(name string) string
- func CheckErr(err error)
- func ClearColorCode(str string) string
- func CreateAnchor(str string) string
- func CreateSuperiorDir(path string) bool
- func Date(format string, timestamp int64, timezone ...*time.Location) string
- func DateT(format string, t time.Time) string
- func DayStartEndTime(t time.Time, timezone ...*time.Location) (time.Time, time.Time)
- func DebugPrintReflect(x interface{})
- func DefaultGOPATH() string
- func Die(status int)
- func Echo(args ...interface{})
- func EchoF(args interface{})
- func EmptyStruct() struct{}
- func EmptyStructSlice() []struct{}
- func EqualsIgnoreCase(a, b string) bool
- func ExecCmd(cmdName string, args ...string) (string, string, error)
- func ExecCmdBytes(cmdName string, args ...string) ([]byte, []byte, error)
- func ExecCmdDir(dir, cmdName string, args ...string) (string, string, error)
- func ExecCmdDirBytes(dir, cmdName string, args ...string) ([]byte, []byte, error)
- func Exit(status int)
- func ExtractContent4Tag(str, tag string) []string
- func Fen2yuan(price int64, isTrimZero bool) string
- func Fen2yuan4int(price int, isTrimZero bool) string
- func FileExists(path string) bool
- func FileExt(f string) string
- func FileGetContents(filename string) (string, error)
- func FileMTime(file string) (int64, error)
- func FilePutContents(filename string, content string, perm ...os.FileMode) (int, error)
- func FileSize(file string) (int64, error)
- func Float64Rank(data []float64, order string, isRepeatOrder bool) map[float64]int
- func Float64Toint(fNum float64) (int, error)
- func Float64Toint64(fNum float64) (int64, error)
- func FromatUUIDString(s string) string
- func GenerateUserAgent(appname string, ext ...string) string
- func GetCallFuncName() string
- func GetCallInfo() map[string]string
- func GetDefaultTimezone() *time.Location
- func GetEnv(env, defaultValue string) string
- func GetExcelLetter(column int) string
- func GetGoVersion() string
- func GetGwHostEnvName(gwName string) string
- func GetLocalIPV1() []string
- func GetMpVerifyVal(str string) string
- func GetRandString(length int) string
- func GetRandStringWithCharset(length int, charset string) string
- func GetShanghaiTimezone() *time.Location
- func GetStructTagContent(i interface{}, fieldNname string, tagName string) (string, bool)
- func GetSummary(s string, length int) string
- func GetWwVerifyVal(str string) string
- func GitCheckout(codeRootDir string) (string, error)
- func GitPull(codeRootDir string) (string, error)
- func InitStruct4DefaultTag(bean interface{})
- func Int64Filter(data []int64, callBack func(i int64) bool) []int64
- func Int64InSlice(a int64, list []int64) bool
- func Int64s(a []int64)
- func IntFilter(data []int, callBack func(i int) bool) []int
- func IntInSlice(a int, list []int) bool
- func IntSliceToStringSlice(arr []int) ([]string, bool)
- func IntSum(nums ...int) int
- func InterfacetoString(data interface{}, sep string) string
- func IsAccountName(str string) bool
- func IsBlank(str string) bool
- func IsDir(path string) bool
- func IsDirWriteable(dir string) error
- func IsEmpty(val interface{}) bool
- func IsEmptyV2(str string) bool
- func IsFile(path string) bool
- func IsFloatNumber(str string) bool
- func IsMail(mail string) bool
- func IsMobile(str string) bool
- func IsNotBlank(str string) bool
- func IsNotEmptyV2(str string) bool
- func IsNumber(str string) bool
- func IsPhone(str string) bool
- func IsStrMaper(handler interface{}) bool
- func IsUrl(str string) bool
- func IsZeroCode(code interface{}) bool
- func JsonUnmarshal(str string, obj interface{}) error
- func KeysOfMap(m map[string]string) []string
- func KeysOfMapV2(m map[string]interface{}) []string
- func Lcfirst(str string) string
- func LoadJson(jsonFile string, t interface{}) error
- func Map2XML(kvs map[string]string) (text []byte, err error)
- func Map2XMLV2(params map[string]string, rootName ...string) string
- func MbStrlen(str string) int
- func Md5(str string) string
- func Md5File(path string) (string, error)
- func Md5V1(str string) string
- func Md5V2(str string) string
- func Md5V3(str string) string
- func Md5V4(s string) string
- func Md5V5(bt []byte) string
- func MergeStringMap(list ...map[string]string) map[string]string
- func MyAssert(guard bool, str string)
- func NewRedisInfo() redisinfo
- func Nl2br(str string) string
- func PrintErr(err error)
- func RandStr4Byte(n int, way int) string
- func RegexpVerify(val string, reg string) bool
- func RemoveDian00(priceStr string) string
- func RemoveRepeatByFloat32(data []float32) []float32
- func RemoveRepeatByFloat64(data []float64) []float64
- func RemoveRepeatByInt(data []int) []int
- func RemoveRepeatByInt16(data []int16) []int16
- func RemoveRepeatByInt32(data []int32) []int32
- func RemoveRepeatByInt64(data []int64) []int64
- func RemoveRepeatByInt8(data []int8) []int8
- func RemoveRepeatByString(data []string) []string
- func RemoveRepeatContent(data interface{}) (interface{}, error)
- func ReplaceStar4Phone(phone string) string
- func ReplaceStar4String(str string, start int, maxLen int) string
- func ReverseInt64s(a []int64)
- func ShuffleStr(s []string)
- func ShuffleStr4Copy(s []string) []string
- func Sleep(t int64)
- func SliceErrorf(format string, args ...interface{}) error
- func SliceJointoString(data interface{}, sep string, isRemove bool) (string, error)
- func Str2Int(str string) int
- func StrInSlice(a string, list []string) bool
- func StringFilter(data []string, callBack func(s string) bool) []string
- func StringNumber2Int64Slice(data []string) []int64
- func StringNumber2IntSlice(data []string) []int
- func StringSliceToIntSlice(arr []string) ([]int, bool)
- func StripTags(s string, tags ...string) string
- func Strlen(str string) int
- func Strrev(str string) string
- func Strtotime(format, strtime string, timezone ...*time.Location) (int64, error)
- func SubDays(t1, t2 time.Time) (day int)
- func SubTimeStr(t2 time.Time, timezone ...*time.Location) string
- func Substr(str string, start int, end int) string
- func Time(timezone ...*time.Location) int64
- func Time2TimeStr(t *time.Time) string
- func Time2TimeStr2(t time.Time) string
- func TimeFormat2Date(t time.Time) string
- func TimeFormat2DateWay(t time.Time, way int) string
- func TimeNow(timezone ...*time.Location) int64
- func TimeNow2Day(timezone ...*time.Location) int
- func TimeNow2Format(format string, timezone ...*time.Location) string
- func TimeNow2Month(timezone ...*time.Location) int
- func TimeNow2String(timezone ...*time.Location) string
- func TimeNow2YMD(timezone ...*time.Location) (int, int, int)
- func TimeNow2YearMonth(timezone ...*time.Location) int
- func TimeNowMillisecond(timezone ...*time.Location) int64
- func TimeNowPtr() *time.Time
- func TimePtr2Str(t *time.Time) string
- func TimePtr2Str2(t time.Time) string
- func TimeStr2Time(t string) time.Time
- func TimeToSlice(t time.Time) []int
- func Timestamp2DateTime(timestamp int, way int, timezone ...*time.Location) string
- func Timestamp2DateTime4int64(timestamp int64, way int, timezone ...*time.Location) string
- func Timestamp2Time(timestamp int64, timezone ...*time.Location) time.Time
- func ToBool(s string) bool
- func ToBoolOr(s string, defaultValue bool) bool
- func ToCamelCase(str string) string
- func ToColor(code string, msg string) string
- func ToGreen(str string) string
- func ToJson(v interface{}) string
- func ToRed(str string) string
- func ToSnakeCase(str string) string
- func ToStr(value interface{}, args ...int) (s string)
- func ToYellow(str string) string
- func TodayStartEndTime(timezone ...*time.Location) (time.Time, time.Time)
- func Typeof(v interface{}) string
- func Ucfirst(str string) string
- func Uniq(salt string, isFormat bool) string
- func UrlDeal(reqUrl string, otherGetParam string) string
- func Usleep(t int64)
- func Void()
- func WriteContentType(w http.ResponseWriter, value []string)
- func XML2Map(text []byte) (result map[string]string, err error)
- func XmlUnmarshal(str string, obj interface{}) error
- type ArgInt
- type AssertTime
- type Author
- type CDATA
- type ConverterFunc
- type CorsConfig
- type DataManage
- func (dm *DataManage) Get(key string) (value interface{}, exists bool)
- func (dm *DataManage) GetBool(key string) (b bool)
- func (dm *DataManage) GetData() map[string]interface{}
- func (dm *DataManage) GetFloat64(key string) (f64 float64)
- func (dm *DataManage) GetInt(key string) (i int)
- func (dm *DataManage) GetInt64(key string) (i64 int64)
- func (dm *DataManage) GetString(key string) (s string)
- func (dm *DataManage) MustGet(key string) interface{}
- func (dm *DataManage) Set(key string, value interface{})
- type H
- type IdentifyInterface
- type Int64Slice
- type Metadata
- type MyMapStringInt
- type MyMapStringIntList
- type MySliceInt64
- type PIDFile
- type RedisGroupManage
- type Scheme
- type SeqString
- type Sequence
- type SliceError
- type StrMaper
- type StrTo
- func (f StrTo) Float32() (float32, error)
- func (f StrTo) Float64() (float64, error)
- func (f StrTo) Int() (int, error)
- func (f StrTo) Int64() (int64, error)
- func (f StrTo) IntV0() (int, error)
- func (f StrTo) MustFloat32() float32
- func (f StrTo) MustFloat64() float64
- func (f StrTo) MustInt() int
- func (f StrTo) MustInt64() int64
- func (f StrTo) MustUint64() uint64
- func (f StrTo) MustUint8() uint8
- func (f StrTo) String() string
- func (f StrTo) Uint64() (uint64, error)
- func (f StrTo) Uint8() (uint8, error)
- type WrapError
Constants ¶
const ( V1 byte V2 V3 V4 V5 V6 V7 V8 V9 V10 )
版本常量
const ( // 空字符串 Empty = "" // 签名方式 SignTypeMD5 = "MD5" SignTypeHmacSHA256 = "HMAC-SHA256" SignTypeRSA = "RSA" PrivateFileMode = 0600 )
const ( CharsetStr1 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" CharsetStr2 = "0123456789" // 去掉了i、j、l、o、u、v、z、I、J、L、O、U、V、Z、0、1、2字符 CharsetStr3 = "abcdefghkmnpqrstwxyABCDEFGHKMNPQRSTWXY3456789" )
字符及字符串相关常量
const ( TIME_FORMAT = "2006-01-02 15:04:05" TimeFormat = "2006-01-02 15:04:05" DateFormat = "2006-01-02" TFormat = "15:04:05" DTNoSecondsFormat = "2006-01-02 15:04" )
日期时间相关常量
const ( PHP_EOL = "\n" GO_EOL = "\n" )
const ( FgBlack uint8 = iota + 30 // 黑色 FgRed // 红色 FgGreen //绿色 FgYellow //黄色 FgBlue //蓝色 FgFuchsia // 紫红色 FgCyan // 青蓝色 FgWhite // 白色 )
前景色即文字颜色
const ( BgBlack uint8 = iota + 40 BgRed BgGreen BgYellow BgBlue BgFuchsia BgCyan BgWhite )
背景色
const ( // 是否包含html标签 HTMLRegexStr = `<[/]?([a-zA-Z]+).*?>` // 纯字母 LetterRegexStr = "^[a-zA-Z]+$" // 纯数字 NumberRegexStr = "^[0-9]+$" // 字母 + 数字 LetterNumericRegexStr = "^[a-zA-Z0-9]+$" // 正负浮点数、正负整数 NumericRegexStr = "^[-+]?[0-9]+(?:\\.[0-9]+)?$" // 以 #;开头的字符就算是注释行 CommentLineRegexStr = "^\\s*[#;]+" WwVerify = "^WW_verify_([0-9a-zA-Z]{16}).txt$" MpVerify = "^MP_verify_([0-9a-zA-Z]{16}).txt$" )
Variables ¶
This section is empty.
Functions ¶
func AlreadyTimeStr ¶
已运行时长: d天h小时m分钟s秒
func ClearColorCode ¶ added in v1.0.4
ClearColorCode 提取颜色样式中的文本内容,示例:fmt.Println(ClearColorCode(ToYellow("goods")))
func CreateAnchor ¶
对特殊字符使用中划线替换 CreateAnchor("abc?你好?中=国123abc") 返回 abc-你好-中-国123abc CreateAnchor("你好中国123abc")返回 你好中国123abc CreateAnchor("你好中国 123 abc") 返回 你好中国-123-abc CreateAnchor("how 你好 中国123a!bc#de") 返回 how-你好-中国123a-bc-de
func DateT ¶
Y年,4位 y年,后2位 m月份,有前导0 n月份,无加前导0 d日,有前导0 j日,无加前导0 H 24小时制,有前导0 G 24小时制,无前导0 h 12小时制,有前导0 g 12小时制,无前导0 i 分钟,有前导0 ii 分钟,无前导0 s 秒,有前导0 ss 秒,无前导0 类似php的写法 Y-m-d H:i:s
func DayStartEndTime ¶
某天的开始时间和结束时间
func DebugPrintReflect ¶
func DebugPrintReflect(x interface{})
调用示例:gosupport.DebugPrintReflect(time.Hour)
func ExecCmdBytes ¶
当前目录作为工作目录来执行命令
func ExecCmdDirBytes ¶
func FilePutContents ¶
写内容
func Float64Rank ¶
排名算法 示例: ret := gosupport.Float64Rank([]float64{-1,0,2.9,3,2.9}, "desc", false)
func FromatUUIDString ¶
返回 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
func GenerateUserAgent ¶
调用示例:gosupport.GenerateUserAgent("user-service", "1.0.0")
func GetCallInfo ¶
func GetLocalIPV1 ¶ added in v1.0.1
func GetLocalIPV1() []string
获取本机ip,一般取第0个单元作为本机ip,示例:ip := gosupport.GetLocalIPV1()[0]
func GetMpVerifyVal ¶ added in v1.0.4
GetMpVerifyVal 提取内容,例如 MP_verify_d4RP2dwJOG3lDBub.txt 提取出 d4RP2dwJOG3lDBub
func GetRandStringWithCharset ¶
获取指定charset字符集下指定长度length的随机字符串
func GetStructTagContent ¶
获取结构体某字段的tag值
func GetWwVerifyVal ¶ added in v1.0.4
GetWwVerifyVal 提取内容,例如 WW_verify_P3fNz9uLSkgAlsnI.txt 提取出P3fNz9uLSkgAlsnI
func GitCheckout ¶ added in v1.0.1
切换到指定目录checkout
func InitStruct4DefaultTag ¶
func InitStruct4DefaultTag(bean interface{})
通过结构体的default标签设置结构体默认值,入参为指针类型
func Int64InSlice ¶
示例:fmt.Println(gosupport.Int64InSlice(9, []int64{5, 6, 9}))
func IntInSlice ¶
func IntSliceToStringSlice ¶
将[]int转为[]string, s,_ := gosupport.IntSliceToStringSlice([]int{123, 78919})
func InterfacetoString ¶
s := gosupport.InterfacetoString([]interface{}{10, 200}, ",")
func IsDirWriteable ¶
func IsNotBlank ¶ added in v1.0.1
func IsStrMaper ¶ added in v1.0.4
func IsStrMaper(handler interface{}) bool
func JsonUnmarshal ¶ added in v1.0.2
func KeysOfMapV2 ¶
func LoadJson ¶
调用示例: data := make(map[string]interface{})
if err :=LoadJson("./cjs.json", &data);err!=nil{ fmt.Println("解析失败", err.Error()) } else {
fmt.Println(data) }
func NewRedisInfo ¶
func NewRedisInfo() redisinfo
func RemoveDian00 ¶
调用示例:gosupport.RemoveDian00("18.00") 返回 18
func RemoveRepeatContent ¶
func RemoveRepeatContent(data interface{}) (interface{}, error)
使用示例 abc,_ := RemoveRepeatContent([]float64{9.9, 18.9, 22, 9.9, 22, 33})
if v,ok := abc.([]float64);ok{ fmt.Println(v[2]) //22 }
func ReplaceStar4String ¶
从开始位置替换为*号 start开始位置-从0开始计算,maxLen最多打星个数
func ShuffleStr4Copy ¶ added in v1.0.1
func SliceJointoString ¶
把切片内容拼接成字符串
func StringFilter ¶
过滤字符串切片内容 示例:
s1 := []string{"hello", "", "yes", "0","yes"} s2 := gosupport.StringFilter(s1, func(s string) bool { if s == "" || s == "0" { return false } return true })
func StringNumber2Int64Slice ¶
func StringNumber2IntSlice ¶
func StringSliceToIntSlice ¶
将[]string转为[]int, s,_ := gosupport.StringSliceToIntSlice([]string{"123", "78919"})
func Strtotime ¶
按日期格式+时间转时间戳 unixTime,_ := gosupport.Strtotime(gosupport.TimeFormat,"2021-01-02 02:36:43")
func SubTimeStr ¶
1分钟以内显示为:刚刚 1小时以内显示为:N分钟前 当天以内显示为:今天 N点N分(如:今天 22:33) 昨天时间显示为:昨天 N点N分(如:昨天 10:15) 在今年显示为:N月N日 N点N分(如:02月03日 09:33) 今年以前显示为:N年N月N日 N点N分(如:2020年09月18日 15:59)
func TimeFormat2Date ¶
调用示例:gosupport.TimeFormat2Date(time.Date(2019, 07, 01, 0, 0, 0, 0, time.UTC)) 返回格式为 年/月/日,如:2019/07/01 、 2019/11/28
func TimeNow2Format ¶
当前时间转指定日期格式,s:= gosupport.TimeNow2Format("20060102") fmt.Println(gosupport.TimeNow2Format("2006.01.02 15:04:05"))
func TimeNow2String ¶
当前时间转年月日格式,返回示例:20191128
func TimeNow2YearMonth ¶
当前时间转年月格式,返回示例:201911
func TimeNowMillisecond ¶ added in v1.0.4
TimeNowMillisecond 获取毫秒
func TimePtr2Str2 ¶
func TimeStr2Time ¶
func TimeToSlice ¶
func Timestamp2DateTime ¶
时间戳转日期时间格式,调用示例: gosupport.Timestamp2DateTime(1569152644, 7)
func Timestamp2DateTime4int64 ¶
时间戳转日期时间格式,调用示例: gosupport.Timestamp2DateTime4int64(1622039023, 1)
func Timestamp2Time ¶ added in v1.0.3
时间戳转time.Time对象
func ToCamelCase ¶
转为小驼峰格式: 空格的首字母转大写,如:hello world_abc厉害 转 helloWorld_abc厉害
func ToSnakeCase ¶
转为snake格式: 全部转小写,空格转_,如:Abc_Xy z_eLsW中国 转 abc_xy_z_elsw中国
func TodayStartEndTime ¶
今天开始时间和结束时间
func WriteContentType ¶ added in v1.0.4
func WriteContentType(w http.ResponseWriter, value []string)
func XmlUnmarshal ¶ added in v1.0.4
Types ¶
type AssertTime ¶
type AssertTime struct { // 支持的日期格式 TimeFormats []string }
func NewAssertTime ¶
func NewAssertTime() *AssertTime
func (*AssertTime) ParseAssertFormat ¶
func (m *AssertTime) ParseAssertFormat(str string, location *time.Location) (t time.Time, err error)
分析并断言的日期时间则返回,否则返回错误
type Author ¶
作者结构体 调用示例: var Authors []gosupport.Author //存批量作者 Authors = append(Authors, gosupport.Author{Name: "张三", Email: "admin@xxx.com"}) Authors = append(Authors, gosupport.Author{Name: "李四", Email: "lisi@xxx.com"})
for _,v:=range Authors{ fmt.Println(v.String()) }
type ConverterFunc ¶
type CorsConfig ¶
type CorsConfig struct { //是否开启跨域,true是,false否 IsOpenCors bool //允许的源,默认*,赋值给 Access-Control-Allow-Origin AllowOrigins string //允许的请求方式,默认*,如GET、POST,赋值给Access-Control-Allow-Methods AllowMethods []string //允许的请求头,赋值给 Access-Control-Allow-Headers AllowHeaders []string //值为 true、false,赋值给Access-Control-Allow-Credentials AllowCredentials bool //赋值给 Access-Control-Max-Age MaxAge time.Duration }
func DefaultCorsConfig ¶
func DefaultCorsConfig() CorsConfig
corsConfig := gosupport.DefaultCorsConfig()
func (*CorsConfig) AddAllowHeaders ¶
func (c *CorsConfig) AddAllowHeaders(headers ...string)
设置允许的请求头
func (*CorsConfig) AddAllowMethods ¶
func (c *CorsConfig) AddAllowMethods(methods ...string)
设置允许的请求方式
func (*CorsConfig) GenerateHttpHeaders ¶
func (c *CorsConfig) GenerateHttpHeaders() http.Header
生成http类型头,类型:type Header map[string][]string
type DataManage ¶
func NewGlobalCfgSingleton ¶
func NewGlobalCfgSingleton() *DataManage
func NewGlobalEnvSingleton ¶
func NewGlobalEnvSingleton() *DataManage
func (*DataManage) Get ¶
func (dm *DataManage) Get(key string) (value interface{}, exists bool)
func (*DataManage) GetBool ¶
func (dm *DataManage) GetBool(key string) (b bool)
func (*DataManage) GetData ¶
func (dm *DataManage) GetData() map[string]interface{}
func (*DataManage) GetFloat64 ¶
func (dm *DataManage) GetFloat64(key string) (f64 float64)
func (*DataManage) GetInt ¶
func (dm *DataManage) GetInt(key string) (i int)
func (*DataManage) GetInt64 ¶
func (dm *DataManage) GetInt64(key string) (i64 int64)
func (*DataManage) GetString ¶
func (dm *DataManage) GetString(key string) (s string)
func (*DataManage) MustGet ¶
func (dm *DataManage) MustGet(key string) interface{}
func (*DataManage) Set ¶
func (dm *DataManage) Set(key string, value interface{})
type H ¶ added in v1.0.4
type H map[string]interface{}
func (H) MarshalXML ¶ added in v1.0.4
MarshalXML allows type H to be used with xml.Marshal.
func (H) ToJsonByte ¶ added in v1.0.4
func (H) WriteContentType ¶ added in v1.0.4
func (h H) WriteContentType(w http.ResponseWriter, value []string) H
type Int64Slice ¶
type Int64Slice []int64
myInt64 := []int64{9, 8,10,7} sort.Sort(gosupport.Int64Slice(myInt64)) // 升序,或者 gosupport.Int64s(myInt64) 或者 gosupport.Int64Slice(myInt64).Sort() fmt.Println(myInt64) //[7 8 9 10]
func (Int64Slice) Len ¶
func (x Int64Slice) Len() int
func (Int64Slice) Less ¶
func (x Int64Slice) Less(i, j int) bool
func (Int64Slice) Sort ¶
func (x Int64Slice) Sort()
func (Int64Slice) Swap ¶
func (x Int64Slice) Swap(i, j int)
type MyMapStringInt ¶
type MyMapStringIntList ¶
type MyMapStringIntList []MyMapStringInt
func MapSortByValue ¶
func MapSortByValue(m map[string]int, so string) MyMapStringIntList
对map的int值排序, ret := gosupport.MapSortByValue(map[string]int{"abc":123, "xyz":4}, "desc")
func (MyMapStringIntList) Len ¶
func (p MyMapStringIntList) Len() int
func (MyMapStringIntList) Less ¶
func (p MyMapStringIntList) Less(i, j int) bool
func (MyMapStringIntList) Swap ¶
func (p MyMapStringIntList) Swap(i, j int)
type MySliceInt64 ¶
type MySliceInt64 struct {
// contains filtered or unexported fields
}
func (*MySliceInt64) GetData ¶
func (m *MySliceInt64) GetData() []int64
func (*MySliceInt64) RemoveRepeatData ¶
func (m *MySliceInt64) RemoveRepeatData() []int64
func (*MySliceInt64) SetData ¶
func (m *MySliceInt64) SetData(d []int64)
type PIDFile ¶
type PIDFile struct {
// contains filtered or unexported fields
}
对pid文件的操作
func NewPIDFile ¶
调用示例: pidFile := "/data/www/go-community-service/go-community-service.pid" pidFileObj := gosupport.NewPIDFile(pidFile) err := pidFileObj.CreatePidFile(os.Getpid())
if err !=nil { fmt.Println(err.Error()) }
pid2,_ := pidFileObj.GetPid() fmt.Println("pidfile=", pidFile, "pid=", pid2) pidFileObj.Remove()
func (PIDFile) CreatePidFile ¶
创建pid文件,存在pid文件则写失败, pid=os.Getpid()
type RedisGroupManage ¶
type RedisGroupManage struct {
// contains filtered or unexported fields
}
redis组管理
func NewRedisGroupManage ¶
func NewRedisGroupManage() *RedisGroupManage
func (RedisGroupManage) Get ¶
func (this RedisGroupManage) Get(groupName string) (redisinfo, error)
func (RedisGroupManage) GetPrefix ¶
func (this RedisGroupManage) GetPrefix(groupName string) string
获取当前redis组的配置key前缀
func (*RedisGroupManage) Set ¶
func (this *RedisGroupManage) Set(groupName string, cfg redisinfo)
func (*RedisGroupManage) SetMap ¶
func (this *RedisGroupManage) SetMap(groupName string, info map[string]interface{})
type SeqString ¶ added in v1.0.2
type SeqString string
func (SeqString) GetUidMod4Seq ¶ added in v1.0.2
func (SeqString) GetUidMod4Seq2Str ¶ added in v1.0.2
type Sequence ¶ added in v1.0.2
type Sequence struct {
// contains filtered or unexported fields
}
Sequence seq字符串格式:%s%s%06s%03s 分别是 前缀+(6位年月日*100000+5位时间差(当前时间戳-今天凌晨时间戳))+ (步长%999999=前导补零的6位串) +(用户ID%128)
func NewSequence ¶ added in v1.0.2
func NewSequence() *Sequence
func (*Sequence) SetStepSize ¶ added in v1.0.2
type SliceError ¶
type SliceError struct {
Msg string
}
切片错误结构体
func (*SliceError) Error ¶
func (e *SliceError) Error() string
type StrTo ¶
type StrTo string
使用示例: gosupport.StrTo("123456789").MustUint64()