Standard library / net/http
http.ParseHTTPVersion()
Parse an HTTP version token; ok distinguishes invalid syntax. This does not negotiate or enable a protocol. Expected stdout: '1 1 true\n'.
Formal Syntax & Structure
go syntaxgo
func ParseHTTPVersion(vers string) (major, minor int, ok bool)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| vers | string | HTTP version string such as HTTP/1.1. |
Return Value
(major, minor int, ok bool)
Operation result; check errors and validity indicators when returned.
Working Example
Example Snippetgo
package main
import ( "fmt" "net/http")
func main() { major, minor, ok := http.ParseHTTPVersion("HTTP/1.1"); fmt.Println(major, minor, ok) }
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) }}