What's New

IBM Cloud Functions Adds Native Support for Go 1.11

Share this post:

What’s happening with IBM Cloud Functions and Go?

I’m excited to announce that IBM Cloud Functions officially supports Go natively. Previously, we explained how to use Docker Actions in order to work with Go, but this was not native to Go developers. Now, Go developers can write a function and process the input and the output with normal function parameters and return values.

Ready to try it out?

You can deploy an example action by using the IBM Cloud CLI. Console UI support for Go is coming soon.

Here is a simple hello world action:


// Main says Hello
func Main(params map[string]interface{}) map[string]interface{} {
  name, ok := params["name"].(string)
  if !ok {
    name = "World"
  }
  res := make(map[string]interface{})
  res["body"] = "Hello " + name + "!"
  return res
}

Create a web action with the IBM Cloud Functions CLI plugin. Note: As a best practice, always specify the kind when you use the CLI to be sure that you are working with the version of the language that you expect:
ibmcloud fn action update helloGo hello.go --kind go:1.11 --web true

Next, get the URL for the web action and open it in your browser:
ibmcloud fn action get helloGo --url

Compile for production

To avoid latency with cold starts, it’s recommended that you compile and deploy your Go Action executable. By doing so, the action doesn’t have to compile the code in the first invocation. Another benefit is that compiling your code allows you to use multiple source files and vendor dependency libraries.

Further learning

To see how easy it is to set a project and compile and deploy your Go Action, check out the documentation.

Senior Technical Staff Member (STSM) - IBM Cloud Functions

More What's New stories
May 3, 2019

Kubernetes Tutorials: 5 Ways to Get You Building Fast

Ready to start working with Kubernetes? Want to build your Kubernetes skills? The five tutorials in this post will teach you everything you need to know about how to manage your containerized apps with Kubernetes.

Continue reading

May 3, 2019

Using Portworx to Deploy and Manage an HA MySQL Cluster on IBM Cloud Kubernetes Service

This tutorial is a walkthrough of the steps involved in deploying and managing a highly available MySQL cluster on IBM Cloud Kubernetes Service.

Continue reading

May 2, 2019

Kubernetes v1.14.1 Now Available in IBM Cloud Kubernetes Service

We are excited to announce the availability of Kubernetes v1.14.1 for your clusters that are running in IBM Cloud Kubernetes Service. IBM Cloud Kubernetes Service continues to be the first public managed Kubernetes service to support the latest upstream versions from the community.

Continue reading