I am a beginner with go so bear with me on this. I have an interface defined as the following:
type DynamoTable interface {
Put(item interface{}) interface{ Run() error }
}
also I have a Repo
struct like so:
type TenantConfigRepo struct {
table DynamoTable
}
and i have a struct dynamo.Table
which has a Put
function defined like so:
func (table dynamo.Table) Put(item interface{}) *Put
and the Put
struct has a Run
function as follows:
func (p *Put) Run() error
What I am trying to do is have a generic DynamoTable
interface which will then be used for mocking and unit tests. however this is causing an issue with creating a new Repo:
func newDynamoDBConfigRepo() *TenantConfigRepo {
sess := session.Must(session.NewSession())
db := dynamo.New(sess)
table := db.Table(tableName) //=> this returns a type dynamo.Table
return &TenantConfigRepo{
table: table,
}
}
This however is throwing an error like so
cannot use table (variable of type dynamo.Table) as DynamoTable value in struct literal: wrong type for method Put (have func(item interface{}) *github.com/guregu/dynamo.Put, want func(item interface{}) interface{Run() error})
this is very strange for me because from what i see is the interface that has a Run() error
should be sufficient for the Put
struct since it has the same signature. I am not sure what i am doing wrong here.
Thanks!.