tools

package
v1.1.16 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2021 License: GPL-3.0 Imports: 23 Imported by: 5

Documentation

Index

Constants

View Source
const (
	SecondsPerDay  = 24 * 60 * 60
	SecondsForever = SecondsPerDay * 365 * 10 //10年(int32~(2020+17))
)
View Source
const HTTPPrefixPProf = "/debug/pprof"

Variables

View Source
var (
	TimeZero       = Unix(0, 0)
	TimeOffset     int64
	TimeOffsetPath = "./.timeoffset"
)

Functions

func BeginningOfTheDay

func BeginningOfTheDay(t time.Time) time.Time

func Date

func Date(year int, month time.Month, day, hour, min, sec, nsec int) time.Time

func DiffDay

func DiffDay(t1, t2 time.Time) int32

func Distance

func Distance(p0, p1 Vec3f) float64

func EndingOfTheDay

func EndingOfTheDay(t time.Time) time.Time

func FindMsgByName

func FindMsgByName(msgName string) (protoreflect.MessageType, error)

func GetNextHour

func GetNextHour() time.Time

func GetNextMinute

func GetNextMinute() time.Time

func GetNextTime

func GetNextTime(hour, minute int) time.Time

func GetTimeWithoutHours

func GetTimeWithoutHours(t time.Time) time.Time

func HttpGet

func HttpGet(url string) ([]byte, error)

func HttpPost

func HttpPost(addr string, body []byte) (result []byte, err error)

func HttpPostForm

func HttpPostForm(url string, data url.Values) (result []byte, err error)

func HttpReq

func HttpReq(r *http.Request) *http.Response

func HttpRespCode

func HttpRespCode(w http.ResponseWriter, code int)

func HttpResponse

func HttpResponse(w http.ResponseWriter, data interface{}) (ok bool)

func HttpTransmit

func HttpTransmit(w http.ResponseWriter, r *http.Request, remote string)

func HttpUnmarshalBody

func HttpUnmarshalBody(r *http.Request, data interface{}) (body []byte, ok bool)

func Int32Merge

func Int32Merge(h, l int16) (id int32)

func Int32Split

func Int32Split(id int32) (h, l int16)

func IsInvalidTime

func IsInvalidTime(data time.Time) bool

func IsSameDay

func IsSameDay(time1 time.Time, time2 time.Time) bool

func Magnitude

func Magnitude(v Vec3f) float64

func Maxi32 added in v1.1.13

func Maxi32(x, y int32) int32

func Maxi64 added in v1.1.13

func Maxi64(x, y int64) int64

func MidOfTheDay

func MidOfTheDay(t time.Time) time.Time

func Milliseconds

func Milliseconds() int64

func Mini64 added in v1.1.13

func Mini64(x, y int64) int64

func ModifyTimeOffset added in v1.1.4

func ModifyTimeOffset(add int64)

func MondayBeginWeek

func MondayBeginWeek() int64

func MsgName

func MsgName(msg proto.Message) string

func NextIntervalTime

func NextIntervalTime(t1 time.Time, intervalSeconds int) time.Time

以当天开始时间为初始值 间隔 intervalSeconds触发一次,返回下次触发的时间

func NextMondayBeginWeek

func NextMondayBeginWeek() int64

func Now

func Now() time.Time

func NowTime added in v1.1.13

func NowTime() int64

func PProfInit

func PProfInit(port int32)

func PrintMemUsage added in v1.0.7

func PrintMemUsage()

PrintMemUsage outputs the current, total and OS memory being used. As well as the number of garage collection cycles completed.

func Probability

func Probability(ratio int) bool

简单的概率ratio 1-100

func Probability10000

func Probability10000(ratio int) bool

简单的概率ratio 1-10000

func Randx_y

func Randx_y(x, y int) int

左闭右开 [x,y)

func Seconds

func Seconds() int64

func SqrDistance

func SqrDistance(p0, p1 Vec3f) float64

func SqrMagnitude

func SqrMagnitude(v Vec3f) float64

func TimeFormat

func TimeFormat(data time.Time) string

func TimeParse

func TimeParse(data string) time.Time

func TimeParseFormat

func TimeParseFormat(layout, value string) (time.Time, error)

func Try

func Try(fn func(), catch ...func(ex interface{}))

func UUID

func UUID() string

func Unix

func Unix(sec int64, nsec int64) time.Time

func Valid

func Valid(v Vec3f) bool

Types

type HostInfo added in v1.0.7

type HostInfo struct {
	Total     int32 // 总内存MB
	Used      int32 // 已用内存MB
	Avaliable int32 // 可用内存MB
	CpuUsage  int32 // 使用百分比
	CpuCores  int32 // CPU线程数
}

func GetHostInfo added in v1.0.7

func GetHostInfo() (HostInfo, error)

type HttpHandler

type HttpHandler struct {
	HanderMap map[string]http.Handler
}

func (*HttpHandler) ServeHTTP

func (h *HttpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ProtoParser

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

func NewProtoParser

func NewProtoParser() *ProtoParser

func (*ProtoParser) Init

func (s *ProtoParser) Init(packageName, msgType string) *ProtoParser

协议enum->message自动解析: 1、不区分大消息 2、过滤下划线

func (*ProtoParser) MsgIdToName

func (s *ProtoParser) MsgIdToName(msgId int32) (msgName string, ok bool)

func (*ProtoParser) MsgNameToId

func (s *ProtoParser) MsgNameToId(msgName string) (msgId int32, ok bool)

func (*ProtoParser) UnmarshalPbMsg

func (s *ProtoParser) UnmarshalPbMsg(msgType int32, data []byte) proto.Message

type Vec3f

type Vec3f struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
	Z float64 `json:"z"`
}

func Add

func Add(l, r Vec3f) Vec3f

func Div

func Div(v Vec3f, d float64) Vec3f

func Invalid

func Invalid() Vec3f

func Mul

func Mul(v Vec3f, d float64) Vec3f

func Sub

func Sub(l, r Vec3f) Vec3f

func (*Vec3f) Add

func (s *Vec3f) Add(v Vec3f)

func (*Vec3f) String

func (s *Vec3f) String() string

func (*Vec3f) Sub

func (s *Vec3f) Sub(v Vec3f)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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