Skip to content

Instantly share code, notes, and snippets.

@mjsir911
Created January 21, 2023 19:49
Show Gist options
  • Select an option

  • Save mjsir911/607d1cf5f4765716901308fdab64dfb1 to your computer and use it in GitHub Desktop.

Select an option

Save mjsir911/607d1cf5f4765716901308fdab64dfb1 to your computer and use it in GitHub Desktop.
package main
import (
"io"
"os"
)
type nopCloser[T io.Reader | io.Writer] struct {
T
}
func NopCloser[T io.Reader | io.Writer](r T) nopCloser[T] {
return nopCloser[T]{r}
}
func (nopCloser[T]) Close() error { return nil }
func main() {
a := NopCloser(os.Stdin)
_, err := a.Seek(10, 1)
panic(err)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment