Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Some simple get examples using SendGrid's REST against Github API
package main
import (
func main() {
// var
url := ""
method := rest.Get
// make request and catch err
request := rest.Request{
Method: method,
BaseURL: url,
resp, err := rest.API(request)
if err != nil {
// Unmarshal body into body_map
body := []byte(resp.Body)
var body_iface interface{}
err = json.Unmarshal(body, &body_iface)
if err != nil {
body_map := body_iface.(map[string]interface{})
// lets select format with some output
fmt.Printf("Response: %v\n", resp.StatusCode)
fmt.Printf("Body: %v\n", body_map["current_user_url"].(string))
fmt.Printf("Headers: %v\n", resp.Headers["Status"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.