_, ok := r.(WriterTo)

_, ok := r.(WriterTo)
 
// NopCloser returns a ReadCloser with a no-op Close method wrapping
// the provided Reader r.
// If r implements WriterTo, the returned ReadCloser will implement WriterTo
// by forwarding calls to r.
func NopCloser(r Reader) ReadCloser {
    if _, ok := r.(WriterTo); ok {
        return nopCloserWriterTo{r}
    }
    return nopCloser{r}
}
posted @ 2023-06-22 10:42  papering  阅读(29)  评论(0编辑  收藏  举报