func main() { // // Prompt user for Github username/password // var username string fmt.Printf("Github username: "******"%s", &username) if err != nil { log.Fatal(err) } passwd, err := gopass.GetPass("Github password: "******"scopes"` Note string `json:"note"` }{ Scopes: []string{"public_repo"}, Note: "testing Go napping" + time.Now().String(), } // // Struct to hold response data // res := struct { Id int Url string Scopes []string Token string App map[string]string Note string NoteUrl string `json:"note_url"` UpdatedAt string `json:"updated_at"` CreatedAt string `json:"created_at"` }{} // // Struct to hold error response // e := struct { Message string Errors []struct { Resource string Field string Code string } }{} // // Setup HTTP Basic auth for this session (ONLY use this with SSL). Auth // can also be configured on a per-request basis when using Send(). // s := napping.Session{ Userinfo: url.UserPassword(username, passwd), } url := "https://api.github.com/authorizations" // // Send request to server // resp, err := s.Post(url, &payload, &res, &e) if err != nil { log.Fatal(err) } // // Process response // println("") if resp.Status() == 201 { fmt.Printf("Github auth token: %s\n\n", res.Token) } else { fmt.Println("Bad response status from Github server") fmt.Printf("\t Status: %v\n", resp.Status()) fmt.Printf("\t Message: %v\n", e.Message) fmt.Printf("\t Errors: %v\n", e.Message) pretty.Println(e.Errors) } println("") }