On Jan 12, 2021, at 5:40 AM, Kevin Chadwick <m8il1i...@gmail.com> wrote: > > On 1/12/21 9:43 AM, Axel Wagner wrote: >> git init >> go mod init <module-path> >> >> I guess you *could* safe the `git init` part, but is that really worth the >> added >> complexity? > > <snip> > I usually init git from within vscode afterwards. I wonder if doing it pre > would > save me any trouble. > > AFAICT go mod init works great, if you use remote git. > > If you work locally then you have to manually edit the .mod files. For me > with a > replace directive to bring in general libraries. That is the likely scenario > of > a new user. I have noticed that GoPATH is more prominent again in the docs.
Truthfully, "git init" isn't required at all if you're not going to share. You can name your module whatever you want in go.mod and as long as you're consistent with it elsewhere in your local project, it works fine. I understand the need for the domain as part of the module namespacing, but it does make a certain assumption that all of these things are going to be on resolvable domains, which isn't true for everyone. This is particularly a hassle when building with additional local resources so that you can test new library changes without having to do a full push to a remote git server, update go.sum, etc. And I've still got a bit of a bee in my bonnet about the lack of workable relative imports, but I'm not interested in relitigating that right now. What I wonder might be useful is if go.[mod,sum] were able to pick up additional local overrides (e.g. a go.mod.local file to do the replace directives to point to local variants, with go.sum.local taking the corresponding changes so they don't wind up in go.sum). We've run into this problem quite a bit at work where people point at their local workspaces and then accidentally commit the modified go.mod (often when they've made an actual change to go.mod that needs to be committed and they forget to temporarily remove it). That way, go.mod.local would be easy enough to add to .gitignore, .dockerignore, etc. so that it doesn't escape into the wild. - Dave -- 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 golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/7AF6EBB3-7E69-4180-BF2C-8E2C7446D4E8%40gmail.com.