Using environment variables - Amazon Lambda
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Using environment variables

To access environment variables in Go, use the Getenv function.

The following explains how to do this. Note that the function imports the fmt package to format the printed results and the os package, a platform-independent system interface that allows you to access environment variables.

package main import ( "fmt" "os" "" ) func main() { fmt.Printf("%s is %s. years old\n", os.Getenv("NAME"), os.Getenv("AGE")) }

For a list of environment variables that are set by the Lambda runtime, see Defined runtime environment variables.