Created
September 20, 2020 07:28
-
-
Save shubhag/343d47663a2830d0d5d6fe9696c0c7b9 to your computer and use it in GitHub Desktop.
Custom writer iteration 2
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
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