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.5 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # go-writeas
  2. [![godoc](https://godoc.org/go.code.as/writeas.v2?status.svg)](https://godoc.org/go.code.as/writeas.v2)
  3. Official Write.as Go client library.
  4. ## Installation
  5. **Warning**: the `v2` branch is under heavy development and its API will change without notice.
  6. For a stable API, use `go.code.as/writeas.v1` and upgrade to `v2` once everything is merged into `master`.
  7. ```bash
  8. go get go.code.as/writeas.v2
  9. ```
  10. ## Documentation
  11. See all functionality and usages in the [API documentation](https://developer.write.as/docs/api/).
  12. ### Example usage
  13. ```go
  14. import "go.code.as/writeas.v2"
  15. func main() {
  16. // Create the client
  17. c := writeas.NewClient()
  18. // Publish a post
  19. p, err := c.CreatePost(&writeas.PostParams{
  20. Title: "Title!",
  21. Content: "This is a post.",
  22. Font: "sans",
  23. })
  24. if err != nil {
  25. // Perhaps show err.Error()
  26. }
  27. // Save token for later, since it won't ever be returned again
  28. token := p.Token
  29. // Update a published post
  30. p, err = c.UpdatePost(p.ID, token, &writeas.PostParams{
  31. Content: "Now it's been updated!",
  32. })
  33. if err != nil {
  34. // handle
  35. }
  36. // Get a published post
  37. p, err = c.GetPost(p.ID)
  38. if err != nil {
  39. // handle
  40. }
  41. // Delete a post
  42. err = c.DeletePost(p.ID, token)
  43. }
  44. ```
  45. ## Contributing
  46. 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:
  47. * Run `goimports` on all updated .go files.
  48. * Document all exported structs and funcs.
  49. ## License
  50. MIT