This commit is contained in:
azw 2024-08-03 16:17:36 +08:00
parent d40b258a47
commit ba4b733a80

View File

@ -1,18 +1,18 @@
package q5 package q5
import ( import (
"bufio"
"encoding/json" "encoding/json"
"fmt" "fmt"
"hash/crc32"
"io/ioutil" "io/ioutil"
"net" "net"
"net/http" "net/http"
"os" "os"
"reflect" "reflect"
"time"
"sync"
"runtime" "runtime"
"hash/crc32" "sync"
"bufio" "time"
) )
func GetDaySeconds(seconds int64, timeZone int64) int64 { func GetDaySeconds(seconds int64, timeZone int64) int64 {
@ -207,7 +207,7 @@ func NewSlice[T any](s *[]T, len int32, cap int32) {
func NewSliceElement[T any](s *[]T) *T { func NewSliceElement[T any](s *[]T) *T {
v := new(T) v := new(T)
*s = append(*s, *v) *s = append(*s, *v)
return &(*s)[len(*s) - 1] return &(*s)[len(*s)-1]
} }
func AppendSlice[T any](s *[]T, val T) { func AppendSlice[T any](s *[]T, val T) {
@ -219,7 +219,7 @@ func GetTypeName(v interface{}) string {
} }
func PrintCallStack() { func PrintCallStack() {
// 获取当前函数的调用者信息 // 获取当前函数的调用者信息
pc, file, line, ok := runtime.Caller(1) pc, file, line, ok := runtime.Caller(1)
if !ok { if !ok {
fmt.Println("runtime.Caller error") fmt.Println("runtime.Caller error")
@ -242,7 +242,7 @@ func PrintCallStack() {
} }
func GetCallStack() string { func GetCallStack() string {
// 获取当前函数的调用者信息 // 获取当前函数的调用者信息
//pc, file, line, ok := runtime.Caller(1) //pc, file, line, ok := runtime.Caller(1)
_, _, _, ok := runtime.Caller(1) _, _, _, ok := runtime.Caller(1)
if !ok { if !ok {
@ -353,11 +353,20 @@ func CreateCondTimer(ch chan int64, cond *sync.Cond, initSeconds int64) {
} }
} }
func ExcUntilOk(cb func()bool) { func ExcUntilOk(cb func() bool) {
for !cb() { for !cb() {
} }
} }
func ReadTextFile(fileName string) (string, error) {
if f, err := os.Open(fileName); err == nil {
data, err := ioutil.ReadAll(bufio.NewReader(f))
return string(data), err
} else {
return "", err
}
}
func IsDebug() bool { func IsDebug() bool {
return true return true
} }