Skip to content

Instantly share code, notes, and snippets.

@akfaew
Created May 24, 2019 10:01
Show Gist options
  • Save akfaew/36d0fa4e5c8db7cf04ad9520d1cdc50e to your computer and use it in GitHub Desktop.
Save akfaew/36d0fa4e5c8db7cf04ad9520d1cdc50e to your computer and use it in GitHub Desktop.
A working golang example
package main
import (
"context"
"fmt"
"net/http"
geekmail "github.com/geekmail/go-geekmail"
)
func main() {
conf := &geekmail.Conf{
GitHubAuth: geekmail.GitHubAuth{
Repository: "github.com/geekmail/geekmail-sample",
ConfigPath: "config.yaml",
RepoSecret: "password123",
},
UserToken: "XXX",
}
vars := map[string]string{
"To": "John Doe <john@example.com>",
"Name": "John",
}
draft := &geekmail.DraftCreateGitHub{
TemplatePath: "templates/example.template",
Vars: vars,
Labels: []string{"GeekMail"},
}
client := geekmail.NewClient(&http.Client{}, conf)
if resp, err := client.Draft.CreateGitHub(context.Background(), draft); err != nil {
fmt.Printf("Cannot communicate with the API: err=%v\n", err)
} else {
fmt.Printf("GeekMail response: %+v\n", resp)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment