go.mod 文件中新增 replace 信息,内容如下:

module github.com/userName/mainModule

require "github.com/userName/otherModule" v0.0.0
replace "github.com/userName/otherModule" v0.0.0 => "本地包路径"

Accessing local packages within a go module (go 1.11)