jeudi 10 décembre 2020

Writing tests for a Go project with sub packages and vendor folder structure [closed]

I am using the vendor folder structure in my Go project since I am pulling some functions from a private repository. Also, I am using sub-packages to structure the code. But I could not run tests since it fails to import the code from github.com/path-to-my-sub-package.

My folder structure looks like below.

|____pkg
| |____package1
| | |____file1.go (package package1)
| | |____file2.go (package package1)
| | |____file2_test.go (package package1)
| | |____go.mod
| | |____go.sum
| |____util
| | |____go.mod
| | |____go.sum
| | |____file3.go (package util)
| | |____file4.go (package util)
|____vendor
|____function.go
|____go.mod
|____go.sum

So when I want to run file2_test.go, it says that it doesn't have github.com/pkg/util

Eg : It says the project doesn't contain the required package.

> module `my-module@latest` found (v0.0.0-20201027114348-f54ed38bf062),but does not contain package `github.com/path-to-my-sub-package`

Anything I am doing wrong here?

Aucun commentaire:

Enregistrer un commentaire