"Go http.Get()"의 두 판 사이의 차이

 
27번째 줄: 27번째 줄:
==같이 보기==
==같이 보기==
* [[Go 패키지 http]]
* [[Go 패키지 http]]
* [[Go NopCloser]]


==참고==
==참고==

2024년 6월 26일 (수) 16:12 기준 최신판

1 개요[ | ]

Go http.Get()
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	resp, err := http.Get("https://jsonplaceholder.typicode.com/todos/1")
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	bodyBytes, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(bodyBytes))
}

2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}