Hello rob, here's what I do.
For every dir in ~/go/src run go mod init with the dir name.
e.g.:
cd ~/go/src/foo
go mod init foo
cd ~/go/src/bar
go mod init bar
...
If package foo depends on libfoo (also in ~/go/src) you can add a replace
line in foo's go.mod
e.g.
echo "replace libfoo => ../libfoo" >> ~/go/src/foo/go.mod
Then foo can import libfoo with:
import "libfoo"
Before building for the first time run "go get" to download all
dependencies and update the go.mod file.
After that, you won't need GOPATH or having everything in ~/go anymore.
Hope that helps.
On Wed, Feb 24, 2021 at 3:49 AM rob <[email protected]> wrote:
> Hi. I'm a hobby programmer. I've been able to learn and use gopath
> mode for a while. I've accumulated 20+ programs that I use that were
> build using gopath mode. I'm not using a package manager, as all my
> code is in GOPATH, ie, ~/go/src/
>
> I don't understand how to convert this to modules. I've read the blogs
> on golang.org/ref/mod# ... , and still don't understand how to convert
> to modules.
>
> I tried a year or so ago, but I then could not compile anything, so I
> nuked whatever I did and reverted to GOPATH.
>
> I'm looking for a conversion guide for the complete idiot, or for
> dummies if that's preferable.
>
> I'd be satisfied if there was a step by step guide for converting
> ~/go/src/hello.go to modules. I could probably adapt that.
>
> Right now, all documentation I've seen starts by doing git clone
> https://github.com/my-own-code. And then I'm lost.
>
> If this is not the correct forum to post this very basic request for
> help, guidance as to where else I should GO would be helpful.
>
> --rob solomon
>
>
> --
> 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/24b2ccb9-f4f5-83b0-6a1b-6774021ce029%40gmail.com
> .
>
--
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/CAPKajN7MNFUpUkq1APAcumO%2BgrPcSTmeu8iU3DRiTHPqmTVjFQ%40mail.gmail.com.