Announcing The Official Golang Pusher Library

Go is an amazing and powerful language, and for a while we have been receiving a lot of requests from people we meet at events and through our support system about the possibility of using Pusher with Go. Given that it has established itself with an awesome community and increasing traction, there were a few questions as to why there was no official support yet implemented.

Golang Popularity

Up until now there have been a few libraries offering some support for interacting with our API, but we haven’t yet built a fully-fledged, consistently-maintained package. This has been unfortunate, given that Go is an awesome language that’s powerful and fun to write; and indeed, parts of our system are written in Go.

But now we are delighted to announce a new and official Pusher HTTP library for Go. This package allows you to interact with our API to trigger events, authenticate private and presence channels, validate webhooks, and query the state of your channels.

Getting Started

First of all, install the package:

$ go get github.com/pusher/pusher-http-go

Now let’s import it and initialize a client with your app credentials:

package main

import "github.com/pusher/pusher-http-go"

func main(){

  client := pusher.Client{
    AppId: "your_app_id",
    Key: "your_app_key",
    Secret: "your_app_secret",
  }

}

In order to trigger an event, we pass to the Trigger method the channel, the name of the event and the data to send.

data := map[string]string{"message": "hello world"}

client.Trigger("test_channel", "my_event", data)

Now, open the Pusher Debug Console for your app via the Pusher dashboard and trigger the event to view the library in action!

Now, Over To You!

Of course, there’s a lot more you can do with this package beside triggering events. Check out the Github repo to view the full documentation, which includes a table with the all the supported features.

If you would like to contribute then dive right in, fork the repo, and start making some pull requests. Otherwise, if you use the Go library and make something awesome, then make sure to let us know!

Ready to begin?

Start building your realtime experience today.

From in-app chat to realtime graphs and location tracking, you can rely on Pusher to scale to million of users and trillions of messages