I have 2 possibly related issues.
I have a test monorepo setup, with 2 subdirectories (mod1
and mod2
).
Each one of them has a go.mod
file in them, and each of the modules has a single .go
file with basic printing code. in mod2
there is a subdirectory mod2_lib
(that holds one of those simple .go
files with basic printing code), since I read that Go modules are basically their own little GOPATH
's.
Id like to call function Run()
thats in a package mod2/mod2_lib
from mod1
, but all Im getting is build github.com/account_name/test/mod1: cannot find module for path github.com/account_name/test/mod2/mod2_lib
.
here are the files Im using to figure this out:
mod1/t.go
package main
import (
"fmt"
"github.com/account_name/test/mod2/mod2_lib"
)
func main() {
fmt.Println("mod1")
mod2_lib.Run()
}
mod2/mod2_lib/t_lib.go
package mod2_lib
import "fmt"
func Run() {
fmt.Println("RUNS")
}
the second issue is that in this monorepo I'd like to have related Python and Rust code in top-level dirs py
and rust
. So I'd like to place all my Go packages in the go/src
dir. How would other people import this go/src
path into their project (possibly still having the "github.com/account_name/test/mod2/mod2_lib"
as the import path, and not "github.com/account_name/test/go/src/mod2/mod2_lib"
)?
can anyone give me some pointers on these issues? I want to move to using Golang modules, and abandon the GOPATH
.