more simple modules usage questions

56 views
Skip to first unread message

K Richard Pixley

unread,
Aug 19, 2020, 3:12:57 PM8/19/20
to golang-nuts

I have two local git repositories.  Both are go modules.  Call them, foo.com/one and foo.com/two.  Both have go.mod files declaring themselves to be, respectively, foo.com/one and foo.com/two based on go 1.15.

I want to use a package from one in the other. 

import "foo.com/one/pkg/thing1"

Short of publishing one of them on github, how do I do that?  Do I need to copy or symlink something?  Set some environment variables?

Kurtis Rader

unread,
Aug 19, 2020, 3:21:56 PM8/19/20
to K Richard Pixley, golang-nuts
See the "replace" directive in https://golang.org/cmd/go/#hdr-The_go_mod_file. Google "go mod replace local path" and you'll find plenty of articles on this topic, such as https://thewebivore.com/using-replace-in-go-mod-to-point-to-your-local-module/ 


--
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank
Reply all
Reply to author
Forward
0 new messages