9951 explained code solutions for 126 technologies


golangHow to get response status code of HTTP request


package main

import ("net/http"; "os"; "io")

func main() {
  r, _ := http.Get("https://echoof.me")
  print(r.StatusCode)
}ctrl + c
package main

default package declaration

net/http

http package to work with http protocol

http.Get(

executes GET request to the specified URL

.StatusCode

will return request status code