Go Go CloudShare SDK!
To get articles like this free in your inbox, subscribe to our newsletter.

We are excited to announce the availability of our Go-SDK – a Golang wrapper for CloudShare’s REST API.
After Python, C# and Javascript, it’s about time we showed Golang some love.
Getting Started
Eager Go developers, simply run go get github.com/cloudshare/go-sdk/cloudshare
and you’re all set.
The SDK is essentially a wrapper for our REST API. It takes care of all the authentication hassle and lets you get to work quickly, with minimal code.
Simple Example
Here is how to get a list of all your projects on CloudShare:
c := cloudshare.Client{
APIKey: "your API key here",
APIID: "your API id here",
}
var projects = []cloudshare.Project{}
apierr := c.GetProjects(&projects)
What’s Included
The Go SDK actually comes in two flavors: a generic REST API wrapper, with which you can execute any REST API call you find in the docs, and for the most commonly used API calls there are also typed Go structs and methods to make things extra easy.
Generic REST Calls
You can invoke any API call using the Request
method of the Client
:
c := cloudshare.Client{ ... }
apiresponse, apierror := c.Request("GET", "envs", nil, nil)
You can specify the HTTP method (Get, Put, etc.), an optional JSON body and optinal URL parameters. The result is a HTTP response:
type APIResponse struct {}
StatusCode int
Body []byte
Headers http.Header
}
Typed API Calls
The simple example above is actually the same call, but using the typed method GetProjects
, which returns a typed struct slice of Project instances.
Checkout the godoc for a list of all supported calls.
Bonus: cscurl
Developing against a RESTful API is a lot easier when you can use curl
to test API calls. Included in the Go-SDK is a small CLI utility called cscurl
, which is a curl-style tool for interacting with the CloudShare API. In essence, it takes care of the authentication part for you, which is harder to do with the standard curl
utility.
The example above (getting a list of projects) can be done with cscurl
from command-line like so:
$ cscurl https://use.cloudshare.com/api/v3/projects
(Keen observers may wonder how the example above just works, without supplying any credentials. They can be supplied as env-vars. cscurl --help
shows how.)
Setup
You can grab cscurl
from the SDK’s releases page.
Since it’s written in Go, and since Go is awesome, cscurl is available for Linux, Mac, Windows and both 32 & 64 bit.
Go get it
Go forth and hack away using our Go SDK. Fork it, play with it, let us know what you think. We eat our own dog-food, here at CloudShare, and the Go SDK is an essential part of two more Docker-related annoucements soon to come. Stay tuned.
Adorable Creative Commons gopher images in this post by Renee French.
Read our blog post about Docker 1.13
What you should do next…
1. Subscribe to our newsletter:
Subscribe to our newsletter below for the latest news, advice and thought-leadership for software professionals. Or visit our blog to browse our most recent articles.
2. Learn how virtual labs can grow your business:
To learn more about how CloudShare helps software organizations grow revenue, increase efficiency and improve quality, visit our resources page. You’ll be able to browser dozens of valuable white papers, eBooks, webinars, case studies, and brochures.
3. Get a FREE, no obligation demo:
Discover just how easy it is to create your cloud environment—in minutes! One of our friendly virtual labs experts will be happy to:
- Show you the platform in action
- Calculate pricing for your business
- Set you up with a 14-day free trial
- Answer any questions you have
- No pressure or obligation