Go client for the Write.as API https://developers.write.as
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.4 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # go-writeas
  2. [![godoc](https://godoc.org/github.com/writeas/go-writeas?status.svg)](https://godoc.org/github.com/writeas/go-writeas)
  3. Official Write.as Go client library.
  4. ## Installation
  5. ```bash
  6. go get github.com/writeas/go-writeas
  7. ```
  8. ## Documentation
  9. See all functionality and usages in the [API documentation](https://developers.write.as/docs/api/).
  10. ### Example usage
  11. ```go
  12. import "github.com/writeas/go-writeas"
  13. func main() {
  14. // Create the client
  15. c := writeas.NewClient()
  16. // Publish a post
  17. p, err := c.CreatePost(&writeas.PostParams{
  18. Title: "Title!",
  19. Content: "This is a post.",
  20. Font: "sans",
  21. })
  22. if err != nil {
  23. // Perhaps show err.Error()
  24. }
  25. // Save token for later, since it won't ever be returned again
  26. token := p.Token
  27. // Update a published post
  28. p, err = c.UpdatePost(p.ID, token, &writeas.PostParams{
  29. Content: "Now it's been updated!",
  30. })
  31. if err != nil {
  32. // handle
  33. }
  34. // Get a published post
  35. p, err = c.GetPost(p.ID)
  36. if err != nil {
  37. // handle
  38. }
  39. // Delete a post
  40. err = c.DeletePost(p.ID, token)
  41. }
  42. ```
  43. ## Contributing
  44. The library covers our usage, but might not be comprehensive of the API. So we always welcome contributions and improvements from the community. Before sending pull requests, make sure you've done the following:
  45. * Run `goimports` on all updated .go files.
  46. * Document all exported structs and funcs.
  47. ## License
  48. MIT