-2

I use Go on Windows 10 and am having problem.

I've tried running a basic 'Hello, world' Go program using LiteIDE but when run it returns next error:

C:/Program Files (x86)/Go/bin/go.exe build [C:/Users/MyUser/Desktop/Go_projects]
go: cannot find GOROOT directory: c:\go
Error: process exited with code 2.

A lot of people recommend not setting up GOROOT path variable, meaning Go should work fine without it, yet LiteIDE doesn't. Just in case, I had set up GOPATH to C:\Program Files (x86)\Go\bin

S_py_go_Xru
  • 21
  • 1
  • 4
  • run `go env` command in your terminal and see whether GOROOT is there or not. and please share the output. If its not in there, update your bash_profile file with `export PATH=:$PATH`. Installation directory is normally `/usr/local/go/bin` – nipuna Dec 06 '21 at 12:16
  • 1
    @nipuna: `go env` will always show a `GOROOT` value, because that is the root of the Go installation. – JimB Dec 06 '21 at 13:33
  • 1
    The behavior described is what happens when you have GOROOT set incorrectly in your environment. Aside from checking your user env variables, check the ide setting to see how it is calling the Go binary. Did you install Go using the official packages? – JimB Dec 06 '21 at 13:37
  • @JimB looks like I do have problem with GOROOT since I didn't set it but in this article https://dave.cheney.net/2013/06/14/you-dont-need-to-set-goroot-really it says not to set a GOROOT, which is leaving me confused. And yes, I installed Go using official packages. – S_py_go_Xru Dec 06 '21 at 15:03
  • If the go installation is in `C:/Program Files (x86)/Go`, then GOROOT is set _somewhere_, but we unfortunately cannot find that for you. My best guess would be in the ide settings. Verify that you can at use Go normally from the cli, and `GOPATH` should most definitely _not_ be set to `C:\Program Files (x86)\Go\bin`. Sometimes when after missing up the installation when starting out it's easier to just clean out everything and start again. – JimB Dec 06 '21 at 16:07

1 Answers1

0

I had removed GOROOT from win32.env in liteIDE settings and everything seemed to just work. View > Options > LiteEnv > double-click win32.env > delete GOROOT

I don't know the longlasting consequences of this action yet, but for now this solution seems to work.

S_py_go_Xru
  • 21
  • 1
  • 4