Skip to content

writeas/go-writeas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

bbe9a57 · Jan 8, 2025
Aug 15, 2019
Sep 30, 2015
Sep 5, 2016
Mar 16, 2023
Aug 15, 2019
Dec 25, 2018
Oct 14, 2021
Oct 14, 2021
Nov 26, 2021
Aug 15, 2019
May 28, 2019
Oct 14, 2020
Oct 14, 2020
Jan 8, 2025
Jan 8, 2025
Oct 15, 2021
Nov 26, 2021
May 28, 2019
Mar 16, 2023
Jan 8, 2025

Repository files navigation

go-writeas

godoc

Official Write.as Go client library.

Installation

go get github.com/writeas/go-writeas/v2

Documentation

See all functionality and usages in the API documentation.

Example usage

import "github.com/writeas/go-writeas/v2"

func main() {
	// Create the client
	c := writeas.NewClient()

	// Publish a post
	p, err := c.CreatePost(&writeas.PostParams{
		Title:   "Title!",
		Content: "This is a post.",
		Font:    "sans",
	})
	if err != nil {
		// Perhaps show err.Error()
	}

	// Save token for later, since it won't ever be returned again
	token := p.Token

	// Update a published post
	p, err = c.UpdatePost(p.ID, token, &writeas.PostParams{
		Content: "Now it's been updated!",
	})
	if err != nil {
		// handle
	}

	// Get a published post
	p, err = c.GetPost(p.ID)
	if err != nil {
		// handle
	}

	// Delete a post
	err = c.DeletePost(p.ID, token)
}

Contributing

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:

  • Run goimports on all updated .go files.
  • Document all exported structs and funcs.

License

MIT