Avatar ·

Error "go: go.mod file not found" when trying to run a Go program

Hello everyone! I just started learning Go and encountered a problem. I installed Go on Linux (Ubuntu), wrote a simple "Hello, World!" program in main.go: ```go package main import "fmt" func main() { fmt.Println("Hello, World!") } ``` When I try to run it with the command `go run main.go`, I get the error: ``` go: go.mod file not found in current directory or any parent directory; see 'go help modules' ``` I read that starting from Go 1.16, modules are enabled by default, but I don't understand what that means. Do I need to create some go.mod file? If so, how? And why is it needed for such a simple program? I also tried running with `go run .` — same error. I tried setting the environment variable GO111MODULE=off — then the program runs, but I heard that