Created
January 21, 2023 19:49
-
-
Save mjsir911/607d1cf5f4765716901308fdab64dfb1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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