Fixed the close() functions, also ignore the last commit message i messed it up :3
This commit is contained in:
parent
47970e0051
commit
a05d2cae18
8
main.go
8
main.go
|
@ -67,9 +67,11 @@ func (r *ReadableStream) Close() (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
// We don't want any errors to be thrown if the stream is already closed.
|
// We don't want any errors to be thrown if the stream is already closed.
|
||||||
recovery := recover()
|
recovery := recover()
|
||||||
if !strings.Contains(recovery.(string), "Can not close stream after closing or error") {
|
if !strings.Contains(fmt.Sprint(recovery), "Can not close stream after closing or error") {
|
||||||
|
if recovery != nil {
|
||||||
err = fmt.Errorf("panic: %v", recovery)
|
err = fmt.Errorf("panic: %v", recovery)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
r.lock.Lock()
|
r.lock.Lock()
|
||||||
|
@ -141,9 +143,11 @@ func (w *WritableStream) Close() (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
// We don't want any errors to be thrown if the stream is already closed.
|
// We don't want any errors to be thrown if the stream is already closed.
|
||||||
recovery := recover()
|
recovery := recover()
|
||||||
if !strings.Contains(recovery.(string), "Can not close stream after closing or error") {
|
if !strings.Contains(fmt.Sprint(recovery), "Can not close stream after closing or error") {
|
||||||
|
if recovery != nil {
|
||||||
err = fmt.Errorf("panic: %v", recovery)
|
err = fmt.Errorf("panic: %v", recovery)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
w.lock.Lock()
|
w.lock.Lock()
|
||||||
|
|
|
@ -21,6 +21,10 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Println(string(buffer))
|
fmt.Println(string(buffer))
|
||||||
|
err = readStream.Close()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -34,6 +38,10 @@ func main() {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
err = writeStream.Close()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue