Import Package Without GOROOT?

How do I import a package without a GOROOT set?
I have a directory structure like this.

tempconv/
├── main.go
└── mypackage.go

I am getting the error

archlinux $ go run main.go 
main.go:5:5: package tempconv is not in GOROOT (/usr/local/go/src/tempconv)

The tempconv directory is is /home/$USER/bin/go/.
Will I have to move all the code to /usr/local/go/src/?

Idiomatically you make it a proper module, less idiomatically you start a legacy project using GOPATH which would still require moving your files around, but at least within user writable location.

1 Like

Thank you.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.