Created
December 11, 2017 19:19
-
-
Save underhilllabs/20d528d9430c9015508e3398af51698f to your computer and use it in GitHub Desktop.
a simple go program to print the headers from a URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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