Hi,
I’m a beginner to go and i’m trying to write a program to set the environment values using go code. The env value should be visible when i run export command in bash terminal after executing the go code.
When i run the program it ran successfully os.Getenv and os.Setenv but when i run “export” command (after code execution exits) in shell to see the environment variable “KEY_ID” / “SECRET_ID” and its values i dont see it.
Example code:
package main
import (
“fmt”
“os”
)
func main() {
var err error
if err != nil {
panic(err)
}
os.Setenv(“KEY_ID”, “Hello”)
os.Setenv(“SECRET_ID”, “world”)
fmt.Println(os.Getenv(“KEY_ID”))
fmt.Println(os.Getenv(“SECRET_ID”))
} Output:
Hello
world
Expected:
after this i ran “export” command in terminal window to see the key “KEY_ID” & “SECRET_ID” are exist but i dont see it.
Please advise where i’m wrong and how to achieve it.