You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
416 B
Go
21 lines
416 B
Go
1 year ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"io"
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
resp, _ := http.Get("https://androiddrew.github.io/")
|
||
|
resp_code := resp.StatusCode
|
||
|
fmt.Println("Status code:", resp_code)
|
||
|
body, _ := io.ReadAll(resp.Body)
|
||
|
resp.Body.Close() // prevent memory leak
|
||
|
|
||
|
fmt.Println(string(body))
|
||
|
// resp_body, _ := resp_ptr.Body.Read(resp_ptr.)
|
||
|
// fmt.Println("Body:", string(resp_body))
|
||
|
// resp_ptr.Body.Close()
|
||
|
}
|