env vars
# Node.js
const key = process.env["API_KEY"];
console.log(key);
1
2
3
2
3
Output
$ API_KEY=foobar node examples/env_vars.js
foobar
1
2
2
# Go
package main
import (
"fmt"
"os"
)
func main() {
key := os.Getenv("API_KEY")
fmt.Println(key)
}
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
Output
$ API_KEY=foobar go run examples/env_vars.go
foobar
1
2
2
编辑 (opens new window)
上次更新: 2022/09/30, 11:34:22