Standard library / mime/multipart

multipart.ErrMessageTooLarge

ReadForm signals a resource limit using this sentinel. The example triggers the default 1000-part limit using tiny fields. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
var ErrMessageTooLarge error

Working Example

Example Snippetgo
package main
import (  "bytes"  "errors"  "fmt"  "mime/multipart")
func main() {  var b bytes.Buffer  w := multipart.NewWriter(&b)  check(w.SetBoundary("demo"))  for i := 0; i < 1001; i++ {    check(w.WriteField("a", "x"))  }  check(w.Close())  _, e := multipart.NewReader(&b, "demo").ReadForm(1024)  fmt.Println(errors.Is(e, multipart.ErrMessageTooLarge))}
func must[T any](v T, e error) T {  if e != nil {    panic(e)  }  return v}func check(e error) {  if e != nil {    panic(e)  }}
Go Reference