How to set environment variables that last

前端 未结 4 1791
甜味超标
甜味超标 2020-12-11 04:48

I\'m trying to set some environment variables on my machine using Go OS

    err := os.Setenv(\"DBHOST\", dbHostLocal)
    if err != nil {
        log.Fatalf(         


        
4条回答
  •  醉话见心
    2020-12-11 05:36

    The only way to get the behavior you want is to alter the environment of the current shell, and the easiest way is with a simple shell script

    # setup.sh
    export DBHOST="dbhost.url"
    export CONFIG_VAR_TWO="testing"
    

    and then

    $ source setup.sh
    

提交回复
热议问题