如何解决github.com/golang/mock/gomock
和golang.org/x/net/context
之间的导入周期?据我所知,这个循环存在于两个包之间,我无法在内部修改它们。
目前这些是我的进口商品:
import (
"testing"
"github.com/golang/mock/gomock"
"gopkg.in/mgo.v2" //mock
"gopkg.in/mgo.v2/bson"
)
这是我在运行withmock go test
时收到的确切错误消息:
ERROR: Failed to install 'gopkg.in/mgo.v2': exit status 1
output:
import cycle not allowed
package gopkg.in/mgo.v2
imports github.com/golang/mock/gomock
imports golang.org/x/net/context
imports github.com/golang/mock/gomock