The Go language does not support online editing, but only supports the. zip method (including the upload method of the specified OSS path). Therefore, you must compile and package it locally. This topic describes how to package the Function Compute official Go SDK library with your code.

Prerequisites

Install the Go locale. We recommend that you use Go 1.8 or later.

Compile and deploy (Linux or macOS)

  1. Download the Function Compute Go SDK library.
    go get github.com/aliyun/fc-runtime-go-sdk
  2. Compile the file.
    GOOS=linux go build -o main

    For Linux operating systems, you may also need to configure CGO_ENABLED=0. Example:

    GOOS=linux CGO_ENABLED=0 go build
  3. The package file.
    zip function.zip main

What to do next

After the package is complete, you can upload the package to the Function Compute to complete the deployment. For more information, see the following documents: