background preloader


Facebook Twitter

Create A Simple RESTful API With GoLang. Most modern applications have separation between the backend and the frontend layers.

Create A Simple RESTful API With GoLang

The backend is typically a RESTful API and is critical part of full stack development. These APIs are generally further broken down into a collection of routes, often referred to as endpoints. Building applications like this is often very clean and maintainable in comparison to mashing everything into a single application. I have been creating RESTful APIs with a variety of programming languages, for example Node.js and Java, but lately I’ve been doing a lot of research on the Go programming language. It is fast and very solid programming language that every seems to be talking about.

We’re going to see what it takes to build a simple API that does basic CRUD operations using the Go programming language. For simplicity, we’re not going to be using a database in this example. At this point we’re going to assume Go is already installed and configured on your machine. Create New GoLang Project. Google I/O 2014 CodeLab. How to Write Go Code - The Go Programming Language. Introduction This document demonstrates the development of a simple Go package and introduces the go tool, the standard way to fetch, build, and install Go packages and commands.

How to Write Go Code - The Go Programming Language

The go tool requires you to organize your code in a specific way. Please read this document carefully. It explains the simplest way to get up and running with your Go installation. A similar explanation is available as a screencast. Code organization Overview Go programmers typically keep all their Go code in a single workspace. Note that this differs from other programming environments in which every project has a separate workspace and workspaces are closely tied to version control repositories. Workspaces A workspace is a directory hierarchy with three directories at its root: src contains Go source files, pkg contains package objects, and bin contains executable commands.

The go tool builds source packages and installs the resulting binaries to the pkg and bin directories. The GOPATH environment variable Import paths. The Go Programming Language. Quick web app with Go, Ember.js, and MongoDB. As part of my recent foray into the Go language, I stumbled across this excellent example by Nerdyworm part 1, part 2, part 3 that shows how to build a small web application using the ember.js javascript framework and Go providing the backend server.

Quick web app with Go, Ember.js, and MongoDB

I took this example, fixed up some incompatibilites with the latest version of ember-data.js, and added support for a backing store using MongoDB. You can find all the code for this at my github, while I describe some of the more interesting stuff below. 1 Getting started 1.1 Get my code git clone cd kittens_ember_go setenv GOPATH `pwd`/go/src. Building a REST Service with Golang - Part 1 (Setup) Intro Golang is pretty hot right now.

Building a REST Service with Golang - Part 1 (Setup)

Over the past few weeks, I've been exploring implementing some of the cloud infrastracture I'd previously built with node in go, partly for fun, partly because go is fast. This led me to believe that setting up a basic REST service would make for a great tutorial. At the end, we will have a fully functioning REST service for serving basic CRUD on a user resource.

Code for the final product can be found here. This is the first in a series of high level tutorials on setting up a REST service using golang, focused on getting a go dev environment setup. Setup The first step to start rocking some go is to get it installed. Here we go: $ bash < <(curl -s -S -L $ gvm install go1.4 $ gvm use go1.4 --default. Learn to build and deploy simple Go Web Apps, Part One. In this 4-part series of tutorials, I’m going to take you through the process of creating a fully functioning Go web app called GoView, using just pure Go and deploy to Google App Engine.

Learn to build and deploy simple Go Web Apps, Part One

Hopefully, this will help to demonstrate just how quick and easy it is to use Go for web apps. Let’s begin with the basics. Assumption I am assuming that you have downloaded and installed Go and have set the GOPATH properly. If new to Go, then my previous article has this covered. Google App Engine Google App Engine is different from most other cloud systems because it is neither IaaS (Infrastructure-as-a-Service, e.g., Amazon EC2) nor SaaS (Software-as-a-Service, e.g., Salesforce). Google App Engine lets you run web applications on Google’s infrastructure. Creating an App Engine application is easy, and only takes a few minutes.

Sandbox Developers would not be interested in letting other applications/users get any kind of access to their application code or data.