Standard library / net/http

http.StatusText()

Return the standard reason phrase or empty string for an unknown code. Expected stdout: 'Not Found\n'.

Formal Syntax & Structure

go syntaxgo
func StatusText(code int) string

Parameters & Attributes

NameTypeDescription
codeintHTTP status code.

Return Value

string

Operation result; check errors and validity indicators when returned.

Working Example

Example Snippetgo
package main
import (  "fmt"  "net/http")
func main() { fmt.Println(http.StatusText(404)) }
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