mirror of
https://codeberg.org/superseriousbusiness/gotosocial.git
synced 2024-12-27 03:18:16 +03:00
25 lines
395 B
Go
25 lines
395 B
Go
|
package sse
|
||
|
|
||
|
import "io"
|
||
|
|
||
|
type stringWriter interface {
|
||
|
io.Writer
|
||
|
WriteString(string) (int, error)
|
||
|
}
|
||
|
|
||
|
type stringWrapper struct {
|
||
|
io.Writer
|
||
|
}
|
||
|
|
||
|
func (w stringWrapper) WriteString(str string) (int, error) {
|
||
|
return w.Writer.Write([]byte(str))
|
||
|
}
|
||
|
|
||
|
func checkWriter(writer io.Writer) stringWriter {
|
||
|
if w, ok := writer.(stringWriter); ok {
|
||
|
return w
|
||
|
} else {
|
||
|
return stringWrapper{writer}
|
||
|
}
|
||
|
}
|