您当前的位置: 首页 >  http

qianbo_insist

暂无认证

  • 0浏览

    0关注

    399博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

go https client

qianbo_insist 发布时间:2021-07-11 21:46:24 ,浏览量:0

go https client get

go 语言如何使用https client, 其实还是很简单的,首先要 import “crypto/tls” 然后使用TLSClientConfig

show me the code
package main

import (
	"crypto/tls"
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	tr := &http.Transport{
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
	}
	client := &http.Client{Transport: tr}
	resp, err := client.Get("https://blog.csdn.net/qianbo042311/article/details/118654609")

	if err != nil {
		fmt.Println("error:", err)
		return
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	fmt.Println(string(body))
}
关注
打赏
1663161521
查看更多评论
立即登录/注册

微信扫码登录

0.0410s