Skip to content

Instantly share code, notes, and snippets.

@underhilllabs
Created December 11, 2017 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save underhilllabs/20d528d9430c9015508e3398af51698f to your computer and use it in GitHub Desktop.
Save underhilllabs/20d528d9430c9015508e3398af51698f to your computer and use it in GitHub Desktop.
a simple go program to print the headers from a URL
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
if len(os.Args) < 2 {
fmt.Println("usage: headers <url>")
return
}
response, _ := http.Get(os.Args[1])
for k, v := range response.Header {
fmt.Printf("%s: ", k)
for _, val := range v {
fmt.Print(val)
}
fmt.Println()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment