Very nice looking tests!

Signed-off-by: Kris Nóva <kris@nivenly.com>
This commit is contained in:
Kris Nóva 2021-02-09 16:00:02 -08:00
parent 3b41c9dd5f
commit c1a45bf8e3
149 changed files with 1241 additions and 443 deletions

View file

@ -1,13 +1,13 @@
package concurrent
import (
"io/ioutil"
"log"
"os"
"log"
"io/ioutil"
)
// ErrorLogger is used to print out error, can be set to writer other than stderr
var ErrorLogger = log.New(os.Stderr, "", 0)
// InfoLogger is used to print informational message, default to off
var InfoLogger = log.New(ioutil.Discard, "", 0)
var InfoLogger = log.New(ioutil.Discard, "", 0)

View file

@ -3,11 +3,11 @@ package concurrent
import (
"context"
"fmt"
"reflect"
"runtime"
"runtime/debug"
"sync"
"time"
"reflect"
)
// HandlePanic logs goroutine panic by default

View file

@ -1,10 +1,9 @@
package reflect2
import (
"github.com/modern-go/concurrent"
"reflect"
"unsafe"
"github.com/modern-go/concurrent"
)
type Type interface {
@ -137,7 +136,7 @@ type frozenConfig struct {
func (cfg Config) Froze() *frozenConfig {
return &frozenConfig{
useSafeImplementation: cfg.UseSafeImplementation,
cache: concurrent.NewMap(),
cache: concurrent.NewMap(),
}
}
@ -292,8 +291,8 @@ func UnsafeCastString(str string) []byte {
stringHeader := (*reflect.StringHeader)(unsafe.Pointer(&str))
sliceHeader := &reflect.SliceHeader{
Data: stringHeader.Data,
Cap: stringHeader.Len,
Len: stringHeader.Len,
Cap: stringHeader.Len,
Len: stringHeader.Len,
}
return *(*[]byte)(unsafe.Pointer(sliceHeader))
}