-2

I set GOPATH as an environment variable on my Ubuntu VM as the following: export GOPATH="/go" and it works fine.

The problem is, after I reboot my machine GOPATH is no longer an environment variable.

How to permanently set $PATH on Linux/Unix?, but in my case I need to set an environment variable and not path.

Why is that and how can I set it permanently?

jww
  • 97,681
  • 90
  • 411
  • 885
David Wer
  • 368
  • 3
  • 12
  • 1
    Possible duplicate of [How to permanently set $PATH on Linux/Unix?](https://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux-unix) – AmeyaVS Jun 12 '19 at 08:24
  • Duplicate of: [this](https://unix.stackexchange.com/questions/117467/how-to-permanently-set-environmental-variables) and [this](https://unix.stackexchange.com/questions/117467/how-to-permanently-set-environmental-variables) – AmeyaVS Jun 12 '19 at 08:25
  • I edited my question. I don't think I'm duplicating the question – David Wer Jun 12 '19 at 08:33
  • You have to just paste the command you are manually typing on the terminal at the end of the file. – AmeyaVS Jun 12 '19 at 08:43
  • Possible duplicate of [How to permanently export a variable in Linux?](https://stackoverflow.com/questions/13046624/how-to-permanently-export-a-variable-in-linux) – Jonathan Hall Jul 31 '19 at 11:59

1 Answers1

0

Edit (or create) ~/.bashrc and add the line there. That's assuming that you have stuck to the defaults and not chosen a different shell.

tink
  • 14,342
  • 4
  • 46
  • 50