However importing a main package in another main package works.
To summarize:

1) importing a main package in a external test is supported
2) importing a main package in a main package is supported
3) importing a main package in a non main package is not supported

This seems reasonable to me, however AFAIK it is not documented.

Manlio

Il giorno mercoledì 14 dicembre 2016 17:17:14 UTC+1, rog ha scritto:
>
> It is not possible to import main packages in general, although it does 
> seem to be possible to import a main package from external tests in the 
> same directory.
>
> tst.go: 9:3: import "local/cmd/test" is a program, not an importable 
> package
> I'm not why this restriction exists.
>
>
> On 13 Dec 2016 17:17, "Jan Mercl" <0xj...@gmail.com <javascript:>> wrote:
>
>> On Tue, Dec 13, 2016 at 6:13 PM adonovan via golang-nuts <
>> golan...@googlegroups.com <javascript:>> wrote:
>>
>> > Packages named main are importable, just like any other. Occasionally 
>> this is useful when you want to write tests for members of that package. Of 
>> course, the main function is not exported.
>>
>> I recall running into this limitation years ago. Was it always possible? 
>> Or do I have a false remembrance?
>>
>> -- 
>>
>> -j
>>
>> -- 
>> 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 <javascript:>.
>> 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