Standard library / net/http

http.Response.ProtoAtLeast()

Compare the response protocol version. Expected stdout: 'true false\n'.

Formal Syntax & Structure

go syntaxgo
func (r *Response) ProtoAtLeast(major, minor int) bool

Parameters & Attributes

NameTypeDescription
majorintArgument of the declared type; see example and description.
minorintArgument of the declared type; see example and description.

Return Value

bool

Operation result; check errors and validity indicators when returned.

Working Example

Example Snippetgo
package main
import (  "fmt"  "net/http")
func main() {  r := &http.Response{ProtoMajor: 2}  fmt.Println(r.ProtoAtLeast(1, 1), r.ProtoAtLeast(2, 1))}
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