Skip to content

Instantly share code, notes, and snippets.

@cho0h5
Created December 18, 2021 03:11
Show Gist options
  • Save cho0h5/39c11cec0b644cd64ec7d3a464083979 to your computer and use it in GitHub Desktop.
Save cho0h5/39c11cec0b644cd64ec7d3a464083979 to your computer and use it in GitHub Desktop.
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