package main
import (
"fmt"
"io"
"net/http"
"time"
)
var client = &http.Client{
Timeout: 10 * time.Second, // total request timeout
Transport: &http.Transport{
MaxIdleConns: 100,
MaxIdleConnsPerHost: 10,
IdleConnTimeout: 90 * time.Second,
},
}
func fetch(url string) (string, error) {
resp, err := client.Get(url)
if err != nil { return "", err }
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil { return "", err }
return string(body), nil
}
func main() {
body, err := fetch("https://example.com")
if err != nil {
fmt.Println("error:", err); return
}
fmt.Println("got", len(body), "bytes")
}
Create a free account and build your private vault. Share publicly whenever you want.