Skip to content

Instantly share code, notes, and snippets.

@shubhag
Created September 20, 2020 07:28
Show Gist options
  • Save shubhag/343d47663a2830d0d5d6fe9696c0c7b9 to your computer and use it in GitHub Desktop.
Save shubhag/343d47663a2830d0d5d6fe9696c0c7b9 to your computer and use it in GitHub Desktop.
Custom writer iteration 2
type customWriter struct {
w io.Writer
}
func (e customWriter) Write(p []byte) (int, error) {
n, err := e.w.Write(p)
if err != nil {
return n, err
}
if n != len(p) {
return n, io.ErrShortWrite
}
return len(p), nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment