Standard library / io
io.ErrShortWrite
Indicates a writer reported fewer bytes than requested without providing an error. Some wrappers detect this violation. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
var ErrShortWrite errorWorking Example
Example Snippetgo
package main
import ( "bufio" "fmt" "io")
type shortWriter struct{}
func (shortWriter) Write(p []byte) (int, error) { return len(p) - 1, nil }func main() { w := bufio.NewWriter(io.Writer(shortWriter{})) w.WriteString("abc") fmt.Println(w.Flush() == io.ErrShortWrite)}