The good news is that this is addressed for 1.12:

  #24250 cmd/go: allow "go get" when outside a module in module mode
  https://github.com/golang/go/issues/24250

It would be worthwhile to try the 1.12 release candidate if you can:

  https://groups.google.com/forum/#!topic/golang-announce/r0R2jijOjBo
  
My understanding is that in the lead-up to 1.11, it was a bit debatable how 
it should work, so the thinking was that it would be better to first get 
some more experience as part of the initial modules experiment in 1.11.
  
You can do 'go get' for a binary outside of a module in 1.11, but it is not 
as natural as it is in Go 1.12.  There are a few options outlined here in 
this FAQ (along with some more background, a sample helper script, etc.):

  
https://github.com/golang/go/wiki/Modules#why-does-installing-a-tool-via-go-get-fail-with-error-cannot-find-main-module

That FAQ is a little broader than your specific question, but you can look 
over the 1.11 workarounds listed in that FAQ, which hopefully gives a more 
complete description than my quick comment above.

One option in a particular that is mentioned in that FAQ is 
https://github.com/myitcv/gobin, which is a community tool targeting this 
area of functionality that many people are using now. 'gobin' has a bit 
more flexibility, which you can read about at that repo.

Regards,
thepudds

On Saturday, February 16, 2019 at 7:03:03 AM UTC-5, Manlio Perillo wrote:
>
> Well, the problem is that module aware go get will **still** download 
> commands in GOBIN and **will** cache downloaded modules in
> GOPATH/pkg/mod.
>
> So I don't see a valid reason why it should not work outside a module.
>
> Thanks
> Manlio Perillo
>
> On Saturday, February 16, 2019 at 1:08:08 AM UTC+1, Tyler Compton wrote:
>>
>> It sounds to me like you would want to set GO111MODULE to "auto". My 
>> understanding is that then "go get" will behave like it used to when run 
>> inside of the GOPATH or in a directory tree without a go.mod file.
>>
>> Here's a bit of information about it on the wiki: 
>> https://github.com/golang/go/wiki/Modules#when-do-i-get-old-behavior-vs-new-module-based-behavior
>>
>>
>> On Fri, Feb 15, 2019 at 6:23 AM Manlio Perillo <manlio....@gmail.com> 
>> wrote:
>>
>>> I have started to use go modules recently, and I have set GO111MODULE=on.
>>>
>>> It was unexpected to found that go get does not work outside a module.
>>> As an example:
>>> $ go get github.com/davecheney/godoc2md
>>> go: cannot determine module path for source directory /home/manlio 
>>> (outside GOPATH, no import comments)
>>>
>>> When I used go get inside a module I found that:
>>>
>>> 1. It saves the downloaded packages in the go mod cache
>>> 2. It Installs the command in GOBIN
>>>
>>> These two points can be also done outside a module.
>>>
>>> 3. Add an (indirect) entry in the require section in the go.mod file
>>>
>>> The new entry will, however, be removed by go mod tidy.
>>>
>>> Is it really necessary that go get must only work inside a module?
>>>
>>>
>>> Thanks
>>> Manlio Perillo
>>>
>>> -- 
>>> 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...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to