Created
May 22, 2011 16:08
-
-
Save krikulis/985634 to your computer and use it in GitHub Desktop.
HTTP reader (error) ir golang
This file contains hidden or 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 ( | |
"io" | |
"http" | |
"fmt" | |
) | |
func main() { | |
r, _, err := http.Get("http://www.websvarki.lv/") | |
var b []byte | |
if err == nil { | |
io.ReadFull(r.Body, b) | |
r.Body.Close() | |
} | |
if err != nil { | |
fmt.Println(err.String()) | |
} else { | |
for key, value := range r.Header { | |
fmt.Println(key); | |
fmt.Println(value); | |
} | |
fmt.Println(b); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment