Local modules not found


I have difficulties to migrate my code to use modules:

I have 2 modules, in my GOPATH:

src/project/lib and src/project/app


package lib

import (

func Try() {


package main

import (

func main() {

When GO111MODULE=offit build with no problem.
But when switching to GO111MODULE=onit can find the lib anymore

> go build
build app: cannot load project/lib: cannot find module providing package project/lib

Thanks for your help

1 Like


The GO111MODULE=on option will look at the following path NAME/lib.

In this case, whatever you have initialized the module with the command go mod init NAME will be your starting path. and not project.

you can check the go.mod file, inside that you’ll find the module NAME line. The NAME will be your entry package.

Hope this helps.


Thanks that makes sense.

I believe I need to use the redirect feature to map to the correct path.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.