On Friday, 26 February 2021 at 12:27:09 UTC rob wrote:
> When I try "go mod init" in my /home/rob/go/src, I get an error
>
> go: cannot determine module path for source directory /home/rob/go/src
> (outside GOPATH, module path must be specified)
>
>
What it means is, you must give a name (import path) for your package.
go mod init example
will do. "go mod init github.com/myuser/myproject" is better, if you
intend to publish your project on github for others to be able to import.
However in your case,
go mod init multack
would have been fine. To install it, you should just do "go install" (or
"go install .") in the same directory - not cd out to an outer directory.
Then you'll find it creates a "multack" binary in ~/go/bin
To avoid confusion, do all of this completely outside the ~/go tree. Just
forget that ~/go/src exists.
$ cd
$ mkdir zzz
$ cd zzz
$ go mod init multack
go: creating new go.mod: module multack
$ echo 'package main; func main() {}' >main.go
$ go install
$ ls -l ~/go/bin/multack
-rwxr-xr-x 1 brian staff 1203088 26 Feb 13:37 /Users/brian/go/bin/multack
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/c47d7e02-8658-4ae9-a4e6-769e6f5ad945n%40googlegroups.com.