Project structure
~/vscodego
- hasgo.mod
andgo.sum
and one.go
file~/vscodego/testfiles
hasheap1_test.go test1_file_test.go
Under the directory ~vscodego/testfiles
, trying to generate mock for interface that is in the file heap1_test.go
Command and error as below
princes-MBP:testfiles prince$ mockgen --build_flags=--mod=mod . MyStructIntf
vscodego/testfiles: no non-test Go files in /Users/prince/vscodego/testfiles
vscodego/testfiles: no non-test Go files in /Users/prince/vscodego/testfiles
go: finding module for package go.uber.org/mock/mockgen/model
prog.go:14:2: package vscodego/testfiles is not in GOROOT (/usr/local/Cellar/go/1.20.5/libexec/src/vscodego/testfiles)
2023/07/07 17:11:32 Loading input failed: exit status 1
princes-MBP:testfiles prince$
Contents of the test file heap1_test.go
package testfiles
import "testing"
type MyStruct struct {
age int
Name string
}
func (m *MyStruct) getName() string {
return m.Name
}
type MyStructIntf interface {
getName() string
}
func TestHeap1(t *testing.T) {
}