chore: use go1.18beta1

This commit is contained in:
nadoo committed 2022-01-26 23:40:49 +08:00
1 parent 755a8ca565
commit fac4b86f60
22 files changed
+49 -59

No files matched your search

+6 -6
View File
@@ -6,7 +6,7 @@ import (
)
// F is the main log function.
var F = func(string, ...interface{}) {}
var F = func(string, ...any) {}
// SetFlags sets the output flags for the logger.
func SetFlags(flag int) {
@@ -14,26 +14,26 @@ func SetFlags(flag int) {
}
// Debugf prints debug log.
func Debugf(f string, v ...interface{}) {
func Debugf(f string, v ...any) {
stdlog.Output(2, fmt.Sprintf(f, v...))
}
// Print prints log.
func Print(v ...interface{}) {
func Print(v ...any) {
stdlog.Print(v...)
}
// Printf prints log.
func Printf(f string, v ...interface{}) {
func Printf(f string, v ...any) {
stdlog.Printf(f, v...)
}
// Fatal log and exit.
func Fatal(v ...interface{}) {
func Fatal(v ...any) {
stdlog.Fatal(v...)
}
// Fatalf log and exit.
func Fatalf(f string, v ...interface{}) {
func Fatalf(f string, v ...any) {
stdlog.Fatalf(f, v...)
}
+1 -1
View File
@@ -20,7 +20,7 @@ func init() {
for i := 0; i < num; i++ {
size := 1 << i
sizes[i] = size
pools[i].New = func() interface{} {
pools[i].New = func() any {
return make([]byte, size)
}
}
+4 -6
View File
@@ -6,7 +6,7 @@ import (
)
var bytesBufPool = sync.Pool{
New: func() interface{} { return &bytes.Buffer{} },
New: func() any { return &bytes.Buffer{} },
}
// GetBytesBuffer returns a bytes.buffer from pool.
@@ -16,10 +16,8 @@ func GetBytesBuffer() *bytes.Buffer {
// PutBytesBuffer puts a bytes.buffer into pool.
func PutBytesBuffer(buf *bytes.Buffer) {
if buf.Cap() > 64<<10 {
return
if buf.Cap() <= 64<<10 {
buf.Reset()
bytesBufPool.Put(buf)
}
buf.Reset()
bytesBufPool.Put(buf)
}
+5 -5
View File
@@ -6,12 +6,12 @@ func _itimediff(later, earlier uint32) int32 {
type shaperHeap []writeRequest
func (h shaperHeap) Len() int { return len(h) }
func (h shaperHeap) Less(i, j int) bool { return _itimediff(h[j].prio, h[i].prio) > 0 }
func (h shaperHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] }
func (h *shaperHeap) Push(x interface{}) { *h = append(*h, x.(writeRequest)) }
func (h shaperHeap) Len() int { return len(h) }
func (h shaperHeap) Less(i, j int) bool { return _itimediff(h[j].prio, h[i].prio) > 0 }
func (h shaperHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] }
func (h *shaperHeap) Push(x any) { *h = append(*h, x.(writeRequest)) }
func (h *shaperHeap) Pop() interface{} {
func (h *shaperHeap) Pop() any {
old := *h
n := len(old)
x := old[n-1]