fix writer race condition

This commit is contained in:
juzeon
2024-02-11 20:29:56 -05:00
committed by yuhan6665
parent da1efd8a25
commit 7103888409
3 changed files with 14 additions and 4 deletions
+9
View File
@@ -92,3 +92,12 @@ func RemoveDuplicateStr(strSlice []string) []string {
}
return list
}
func OutWriter(writer io.Writer) chan<- string {
ch := make(chan string)
go func() {
for s := range ch {
_, _ = io.WriteString(writer, s)
}
}()
return ch
}