Skip to content

Instantly share code, notes, and snippets.

@fwojciec
Last active July 23, 2018 09:15
Show Gist options
  • Save fwojciec/1b17212383a9a3afe2e7b799b6979836 to your computer and use it in GitHub Desktop.
Save fwojciec/1b17212383a9a3afe2e7b799b6979836 to your computer and use it in GitHub Desktop.
My solution to "Exercise queries" from Section 01 of Francesc Campoy's Go Web Workshop
// https://github.com/campoy/go-web-workshop/blob/master/section01/README.md
package main
import (
"io"
"log"
"net/http"
"os"
)
func main() {
req, err := http.NewRequest("GET", "https://http-methods.appspot.com/Hungary/", nil)
if err != nil {
log.Fatalf("could not create request: %v", err)
}
client := http.DefaultClient
q := req.URL.Query()
q.Add("v", "true")
req.URL.RawQuery = q.Encode()
res, err := client.Do(req)
if err != nil {
log.Fatalf("http request failed: %v", err)
}
io.Copy(os.Stdout, res.Body)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment