Let’s call this program “playing_with_imports.go”.
package main
import (
"fmt"
// "mat"
)
func main() {
fmt.Println("Hi!")
}
I can run it, via go run playing_with_imports.go
. However, if I uncomment the line containing the word “mat”, thus trying to import the “mat” library, it won’t build. It gives me this error:
playing_with_imports.go:4:10: package mat is not in GOROOT (/nix/store/z3cc4kbqpg8yyy1ak9xzp3b5mi0ydvs9-go-1.17.3/share/go/src/mat)
The problem seems clear: Go libraries are installed in the nix store, so I can’t procedurally download them via whatever mechanism non-NixOS Go programmers use.
How, then, should I download them?