Files
kubevpn/pkg/util/chan_test.go
2024-05-13 19:58:56 +08:00

24 lines
281 B
Go

package util
import (
"fmt"
"testing"
"time"
)
func TestChanClose(t *testing.T) {
c := make(chan any)
close(c)
SafeWrite(c, nil)
c = make(chan any)
go func() {
time.AfterFunc(time.Second*3, func() {
close(c)
})
}()
for a := range c {
fmt.Printf("%v", a)
}
}