Skip to content

Instantly share code, notes, and snippets.

@brancz
Created June 28, 2017 08:55
Show Gist options
  • Save brancz/1c252d4c87a48c80df7c6b046823c466 to your computer and use it in GitHub Desktop.
Save brancz/1c252d4c87a48c80df7c6b046823c466 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
)
func main() {
query := os.Args[1]
fmt.Println("Query:", query)
resp, err := http.Get("http://localhost:9090/api/v1/query?query=" + url.QueryEscape(query))
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment