Standard library / net/http
http.ErrMissingFile
Returned by FormFile when no matching uploaded file exists. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
var ErrMissingFile errorWorking Example
Example Snippetgo
package main
import ( "errors" "fmt" "net/http" "net/http/httptest" "strings")
func main() { r := httptest.NewRequest("POST", "/", strings.NewReader("--demo--\r\n")) r.Header.Set("Content-Type", "multipart/form-data; boundary=demo") _, _, e := r.FormFile("missing") fmt.Println(errors.Is(e, http.ErrMissingFile))}
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) }}