I don't think you can do what you want to do, precisely. But, I do think you can solve your problem!
Instead of actually writing to your environment in the Go code (which can only be seen by *child* processes *of the Go program*!), just print to stdout. That is, instead of os.Setenv("MyPass","Abc.1234"), you would just do fmt.Printf("export %s=%s\n", envVarName, envVarValue), so the output of the program is lines like export MyPass=Abc.1234 export somethingelse=thisotherthing Then take that output and eval it in the shell script. Example: osm@Beast:~/test$ echo "#!/bin/sh > echo export TEST=TRUE > echo export TEST2=FALSE" > test.sh osm@Beast:~/test$ cat test.sh #!/bin/sh echo export TEST=TRUE echo export TEST2=FALSE osm@Beast:~/test$ env | grep TEST osm@Beast:~/test$ ./test.sh export TEST=TRUE export TEST2=FALSE osm@Beast:~/test$ env | grep TEST osm@Beast:~/test$ eval "$(./test.sh)" osm@Beast:~/test$ env | grep TEST TEST=TRUE TEST2=FALSE -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.