免费试用:最火的人工智能查询工具
     最强AI人工智能聊天工具
     对话机器人解答疑难问题
星外智问直连原始API接口(GPT-4o)
➡️未登录受限条数,请登陆使用完整服务>>>➡️
请输入您要问的问题:


查下百度  查下必应

以下是单个问题的回复:

问:请使用go语言写出一个能够批量发送GET请求并返回状态码的程序
GPT答: 7i24.cn
package main

import (
	"fmt"
	"net/http"
)

func main() {
	// 要发送的多个URL
	urls := []string{
		"https://www.baidu.com",
		"https://www.google.com",
		"https://www.apple.com",
	}
	
	ch := make(chan string)
	
	// 并发处理请求
	for _, url := range urls {
		go fetch(url, ch)
	}
	
	// 阻塞等待,直到所有的URL请求结束
	for i := 0; i < len(urls); i++ {
		fmt.Println(<-ch)
	}
}

func fetch(url string, ch chan<- string) {
	resp, err := http.Get(url)
	if err != nil {
		ch <- fmt.Sprintf("%s : %s\n", url, err)
		return
	}
	defer resp.Body.Close()
	
	// 打印Status
	ch <- fmt.Sprintf("%s : %s\n", url, resp.Status)
}
一星  二星  三星  四星  五星 

互联网非法外之地,请不要输入不良内容
 查下百度 查下必应 02-19 23:49:21



chatGPT中国版--星外智问--8v6.CN
当前运行网址:haoadm.com
客服微信:xwgdd_com APP下载 怎么问 识别真假GPT4 使用GPT赚钱 退出登陆