In mylib/tester/tester.go: import ( "fmt "github.com/me/mylib" )
On Wednesday, 2 November 2022 at 08:41:24 UTC Mark wrote: > I have this layout: > ``` > mylib/ > mylib/go.mod # module github.com/me/mylib > mylib/mylib.go > mylib/mylib_test.go > ``` > All this works fine, with both .go files being in the same pkg: mylib. > > However, there are some tests that I can't really do using the test module > because they write to stdout. So I want to create an exe for regression > testing. > > In particular I want the regression tester to be in package main (just > like an app that uses mylib). > > I've tried this layout: > ``` > mylib/ > mylib/go.mod # module github.com/me/mylib > mylib/mylib.go > mylib/mylib_test.go > mylib/tester/tester.go > ``` > But I can't get the import to work: > ```go > package main > > import ( > "fmt" > "mylib" > ) > > func main() { > parser := mylib.Parser() > fmt.Println(parser.AppName(), parser.Version()) > } > ``` > The error I get is `tester/tester.go:8:2: package garg is not in GOROOT`, > which is perfectly correct. > So then I tried to change the import to `../mylib`, but that also produces > an error, `tester/tester.go:8:2: "../mylib" is relative, but relative > import paths are not supported in module mode` > > Is what I'm trying to do possible? If so, how? If not, what d'you > recommend? > > -- 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/f52ebcfd-11c1-4624-baf6-b6a80d12e108n%40googlegroups.com.