Golang 函数库开发:go-huge-util 的自定义之旅

发表时间: 2024-05-30 09:07

封装自定义函数

https://github.com/dablelv/go-huge-util

Go 常用和庞大的实用程序功能帮助您快速轻松地创建您的 Go 程序。

package mainimport (    "fmt"    huge "github.com/dablelv/go-huge-util")func main() {    m := map[string]string{"CN": "China", "HK": "Hong Kong", "AU": "Australia"}    fmt.Println(huge.Map2Slice(m)) // [CN HK AU] [China Hong Kong Australia]}


IsReservedIP("0.0.0.256")    // -1 invalid ipIsReservedIP("39.156.69.79") // 0 public ipIsReservedIP("127.0.0.1")    // 1 reserved ipIPv4StrToU32("127.0.0.1")      // 2130706433U32ToIPv4Str(2130706433)       // "127.0.0.1"GetNativeEndian()              // LittleEndianIsLittleEndian()               // true


tc := NewTimeCounter()// your statementstc.GetMs()                  // get the time cost in millisecondGetNowDate()                // just a example, the same below. 2020-05-16GetNowTime()                // 00:15:42GetNowDateTime()            // 2020-05-16 00:15:42GetNowDateTimeZ()           // 2020-05-16 00:15:42 +08:00GetNowS()                   // 1589559342GetNowMs()                  // 1589559342963GetNowUs()                  // 1589559342963062GetNowNs()                  // 1589559342964063200GetDayBeginMoment(time.Now())  // 2020-05-16 00:00:00 +0800 CSTGetDayEndMoment(time.Now())    // 2020-05-16 23:59:59.999999999 +0800 CST