Avatar ·

How to properly make a GET request and build QueryString in Go?

Hi everyone! I'm new to Go and trying to make a GET request to an API that requires query string parameters. For example, I need to send a request to `https://api.example.com/search?q=golang&page=1&limit=10`. I tried doing it manually by just concatenating the string, but it looks terrible and seems wrong: ```go package main import ( "fmt" "io/ioutil" "net/http" ) func main() { url := "https://api.example.com/search?q=" + "golang" + "&page=" + "1" + "&limit="10" resp, err := http.Get(url) if err != nil { panic(err) } defer resp.Body.Close() body, _ := ioutil.ReadAll(resp.Body) fmt.Println(string(body)) } ``` First, it's unsafe: if the `q` parameter contains spaces or special characters