Hi t hepudds

Yeah this is exactly what I was looking for, thanks a lot.

I search everywhere on the Go website and the Go blog but I didn't go on 
the Github, my bad.

With this help, I'm able to build it but in an other more complicated 
exemple I have an issue : if I add a 2nd library that need the 1st, I have 
a weird error :

go: xxx/myLib@v0.0.0-00010101000000-000000000000: unrecognized import path 
"xxx/myLib" (import path does not begin with hostname) 
go: error loading module requirements

Can I use the "replace design" with any number of project like :
* myLIb
* myWrapper => need myLib
* myBin => need myWrapper

Source code is attached.


Le jeudi 5 septembre 2019 03:57:51 UTC+2, t hepudds a écrit :
>
> Hello Guillaume,
>
> I haven't had a chance to look at your example closely, but it seems you 
> have two modules defined on your local filesystem, with two go.mod files 
> total.
>
> If that is what you are trying to do, one approach is to use a `replace` 
> directive to let one module know about the on-disk location of the other 
> module. Otherwise, they don't know how to find each other.
>
> Also, you usually want to name your modules as if you will publish them 
> someday, which means the `module` line in a go.mod would read something 
> like `module github.com/some/repo` <http://github.com/some/repo>, rather 
> I think you might have something like `module xxx/myLib`, which can be 
> problematic.
>
> In general, when importing code with an import statement, you should 
> always use the full import path, which will start with the module path, 
> such as `import "github.com/some/repo/some/pkg"`. You should always use 
> the full import path when importing packages inside the same modules, as 
> well as when importing packages from a different module.
>
> You can read more about how to use `replace` to let modules find each 
> other on your local filesystem in these two FAQs on the modules wiki:
>
>     FAQ: When should I use the `replace` directive?
>     
> https://github.com/golang/go/wiki/Modules#when-should-i-use-the-replace-directive
>   
>     FAQ: Can I work entirely outside of VCS on my local filesystem?
>     
> https://github.com/golang/go/wiki/Modules#can-i-work-entirely-outside-of-vcs-on-my-local-filesystem
>
> Here is a link to a small runnable example that shows two modules 
> side-by-side on the filesystem that use `replace` to make things work. I 
> think that is at least somewhat similar to what you are trying to do, if I 
> followed:
>
>     https://groups.google.com/d/msg/golang-nuts/1nYoAMFZVVM/eppaRW2rCAAJ
>
> Hope that helps at least somewhat. Please don't hesitate to post more 
> questions or comments.
>
> Regards,
> thepudds
>
> On Sunday, September 1, 2019 at 6:02:21 AM UTC-4, Guillaume Lescure wrote:
>>
>> Hi,
>>
>> Thanks for the comments and the ideas :)
>>
>> 1. Try 'go build ./...'  from the root directory of the module to build 
>>> all the packages in the module.  'go build'  without any arguments is the 
>>> same as 'go build .'  which means just build the current directory/package. 
>>
>>
>> I didn't know the command "go build ./..." and that directly answer my 
>> 1st question, thanks a lot. Now my library is totally built.
>> Thanks a lot for the tips and the explanation (maybe it sould be 
>> documented ?).
>>
>> 2.  With only one go.mod, you should not need a 'replace'  to find local 
>>> code in your own module. 
>>
>>
>> I  have 2 go.mod, 1 in myLib folder and 1 other in myBin folder and I 
>> don't want to merge them.
>> The idea behind that is to simulate 2 repositories, 1 for the library and 
>> 1 for a random application that use that library.
>>
>> 3.  Make sure you use the full import path in any import statements in 
>>> your code when importing other packages, even when importing other packages 
>>> in the same module.  The import path should always start with the module 
>>> path. (The module path what you see on the 'module' line of your go.mod). 
>>>
>>  If that doesn’t help, you might need to share the exact error messages, 
>>> along with the exact go.mod and exact import statements in question. 
>>
>>
>> My code is attached.
>>
>> Regards,
>>  
>>
>>>
>>>
>>> (I am on mobile, so sorry this is brief). 
>>>
>>> Regards, 
>>> thepudds
>>
>>

-- 
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/64d862c6-2fae-462a-b87f-681dabd0c341%40googlegroups.com.

Attachment: testGo.tar.gz
Description: Binary data

Reply via email to