Cannot run Go program (using WSL2 and Goland)

Posted on

I am encountering the following error:

package test is not in GOROOT (/usr/local/go/src/test)

Go path and go root in linux environment

GOVERSION="go1.16"
GOPATH="https://www.reddit.com/home/dan/go-projects"
GOROOT="https://www.reddit.com/usr/local/go"

Directory

> test
    > main.go

Code

package main
import "fmt"
func main() { 
  fmt.Println("hello world!") 
}

Command used to run

In ~/go-projects/src directory,
go run test

Why is it not working?