Created
December 18, 2021 03:11
-
-
Save cho0h5/39c11cec0b644cd64ec7d3a464083979 to your computer and use it in GitHub Desktop.
This file contains 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" | |
"fmt" | |
) | |
type DummyReader struct { | |
} | |
func (d DummyReader) Read(p []byte) (n int, err error) { | |
p[0] = 65 | |
return 1, nil | |
} | |
func main() { | |
var r io.Reader = DummyReader{} | |
fmt.Println("value of r is", r) | |
fmt.Printf("type of r is %T\n", r) | |
p := make([]byte, 10) | |
n, _ := r.Read(p) | |
fmt.Println(p[:n]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment