AWS Lambda has been leading the way in serverless and cloud computing in recent years. So it comes as no surprise that major companies are making the switch to serverless architecture to shorten the time it takes in bringing their products to market and decreased operational costs,

AWS Lambda is a service or FaaS (Function as a Service) provided by Amazon Web Services. It supports a wide array of potential triggers, including incoming HTTP requests, messages from a queue, customer emails, changes to database records, user authentication, messages coming to web sockets, client device synchronization, and much more. One of its best functions is to allow users to focus on the core product and business logic instead of managing the operating system access control, etc.

Then you have Go or Golang. It is a computer programming language whose development began in 2007 at Google, and it was introduced to the public in 2009.

Go is a language loosely based on the syntax of the C programming language, it is a language that is statically typed and contains a garbage collector and memory safety is already a core part of the structure. Go eschews many features of other modern languages, such as method and operator overloading, pointer arithmetic, and type inheritance.

Go is not a free-form language: its conventions specify many formatting details, including how indentation and spaces are to be used. The language requires that none of its declared variables or imported libraries are unused, and all return statements are compulsory.

Go employs “type inference” in variable declarations: the variable type, rather than being an explicit part of the declaration statement, is inferred by the value type itself.

Also, Golang is a compiled language, which means that once you compile it for a certain environment it contains all of the necessary libraries it needs to function. There is no need to upload and install any external libraries with your binary file. Lambda functions are designed to be self-contained, small, and fast, which goes well with the ability to upload a single self-contained file for the Lambda to execute.

So it comes as no surprise to see the marriage of Golang and AWS Lambda in certain workloads.

Getting Started with AWS Lambda and Go

Being that Golang and Lambda have such high compatibility, developing codes that blend the two together isn’t so hard.

You start off by creating an HTTP triggered AWS Lambda function that responds with JSON. We’ll start by building a REST application which manages users, with the application you will be able to create users, get a single user, get a list of users, update a single user or delete a user.

Before we can start, there are a few things we are going to need. First is an AWS account. If you don’t yet have one, you can easily sign up for a free one on the AWS website. The AWS free tier includes one million invocations every month and enough credit to run a single 128MB function continuously, all at no charge. We will be building using AWS CLI.

Next is to make sure we have Golang installed, you can either download an installer from the official website or use your favourite package manager to install it.

With that, we have both Golang and AWS Lambda ready to go.

#aws-lambda #aws #golang #serverless

AWS Lambda in GoLang - The Ultimate Guide
3.95 GEEK