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
March 11, 2019

Worker Node Auto-Scaling GA in IBM Cloud Kubernetes Service

We're extremely excited to announce the general availability of worker node auto-scaling in IBM Cloud Kubernetes Service.

Continue reading

March 8, 2019

IBM Cloud Kubernetes Service Supports CoreDNS

Kubernetes recently announced that CoreDNS has become the default cluster DNS provider starting in version 1.13. To align with this announcement, CoreDNS is also the default cluster DNS provider for new IBM Cloud Kubernetes Service version 1.13 clusters.

Continue reading

March 7, 2019

Modernize Your WebSphere Apps to the Cloud

Mix existing Java EE app capabilities and IBM Cloud services like AI and data analytics with IBM Cloud Application Platform. it combines application modernization and cloud-native application development into a single, consolidated offering.

Continue reading