I have the case dosen't work function
os.GetEnv()
I have set a variable in my system ADDR="192.168.1.100" trought file .bashrc and .profile. So if I open terminal and type below command, I get good result
$ echo $ADDR
192.168.1.100
Why in below very simply program I get Error if variable is correct set in system ?
func main(){
addr := os.Getenv("ADDR")
if addr == "" {
return errors.New("missing addres")
}
}
I also restarted IDE a many times. Tried write in terminal again
$ env ADDR="192.168.1.100"
but still this same effect.
Best Answer
I think the problem is likely that you are not exporting the variable, so the sub process (i.e. you ide, shell, is not getting it).
or