Over a million developers have joined DZone.

Discovering Go and Writing My First Plugin

Author Nicolas Grenie introduces his first Golang plugin after playing around with the language for a day.

· Integration Zone

Build APIs from SQL and NoSQL or Salesforce data sources in seconds. Read the Creating REST APIs white paper, brought to you in partnership with CA Technologies.

One of my new year’s resolutions was to write more often on this blog. I created my own hack day. I would dedicate an entire day to hack on a relatively small project, so I can learn a new technology or a new API. I decided that Thursday was a good day, and so far I’ve been able to write about building a telegram bot for weather using the WeatherUnlocked API and about the APIStrat API. Not as regular as I wanted, but getting there. For last week’s hack day I wanted to get my hands on a programming language I never touched before: Go. I’d heard a lot of good things about it — for one thing it’s supposed to be faster! People have been building more and more stuff in Go, and I’d seen lots of developers using it for their API projects. I had to give it a try. My ultimate goal was to build a package for 3scale in Go, so developers could use our API management solution for their Go API.

I’m not going to argue why Go is a good or a bad language, but I have to say it was not easy for me to tame. For the last few years, I’ve been a heavy JavaScript user. I’ve tried countless JS frameworks for my projects, and I have to confess I’m used to the freedom that JS gives you. Freedom is often synonym for “messing around and not following best practices”, especially in JS, so it was hard to deal with a strongly typed language like Go. It reminds me of my school years writing a connect 4 game in C, counting every byte of memory.

There was a lot of googling involved, a lot of "No way, I can’t do that?", and a lot of complaining to my “gopher” friends. But in the end, I think I managed to ship what I had in mind: a light 3scale package for Go.

It might not be 100% Go friendly, but it’s a work in progress. I hope you gophers out there will help me improve and guide me to write a better version.

You can find the source here. And a project using it here.

On my quest, I also discovered the Gin framework, which seems very appropriate to build APIs in Go. Looks similar to familiar frameworks like Grape in Ruby or Express in JS.

I am curious to hear your thoughts and stories about APIs written in Go and to get some feedback on the package. Send me an email at nicolas@3scale.net or tweet at me @picsoung.

The Integration Zone is brought to you in partnership with CA Technologies.  Use CA Live API Creator to quickly create complete application backends, with secure APIs and robust application logic, in an easy to use interface.

go language,apis

Published at DZone with permission of Nicolas Grenié, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}