Hi everybody,
TL;DR:
Does the presence of a private method on an interface make it impossible to implement that interface outside the package in which it is defined?
Longer story:
This question is not about Gorp, but about implementing an interface that specifies private methods.
But I've gotten to a point where I want to add unittests, and I want to mock out some Gorp functionality.
More precisely I'm trying to create a mock that implements the gorp.SqlExecutor interface which looks kind of like this:
type SqlExecutor interface {
Get(i interface{}, keys ...interface{}) (interface{}, error)
Insert(list ...interface{}) error
Update(list ...interface{}) (int64, error)
Delete(list ...interface{}) (int64, error)
query(query string, args ...interface{}) (*sql.Rows, error)
queryRow(query string, args ...interface{}) *sql.Row
}
Notice the two private methods at the bottom of the interface.
If I try to create a type MockSqlExecutor that implements all the methods in this interface, I get the following error:
go/src/jello/db/db.go:50: cannot use MockSqlExecutor literal (type *MockSqlExecutor) as type gorp.SqlExecutor in assignment:
*MockSqlExecutor does not implement gorp.SqlExecutor (missing gorp.query method)
Does the presence of a private method on an interface make it impossible to implement that interface outside the package in which it is defined?
Am I missing something here?
Thanks!
Octavian.