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
January 21, 2019

IBM Cloud Functions Raises Operations Limits

IBM Cloud Functions already has the ability to run 1,000 concurrent activations, and we're happy to announce that we've raised the memory execution limit to 2Gb (2048 Mb) as well.

Continue reading

December 20, 2018

Announcing the Beta Launch of IBM Digital App Builder

Building a digital app is easy with the IBM Digital App Builder tool. Using this tool, a citizen developer can quickly build a smart app which contains the basic building blocks, connect to microservices, and embed AI services with ease.

Continue reading

December 20, 2018

Announcing Early Access of Voice Agent with Watson Analysis Dashboard

Announcing alpha availability of the Voice Agent with Watson dashboard, providing insights into usage of Watson over the phone.

Continue reading