Came across a tutorial about organizing db access in Go: https://www.alexedwards.net/blog/organising-database-access
I'm following the "Use an interface" approach but bump into an error basically saying I haven't implemented any methods for an interface while I have...
In users.go:
package fs
import (
...
)
func (client *Client) Example_Write() error {
...
return nil
}
func (client *Client) Example_Query() error {
...
return nil
}
In db.go:
type Datastore interface {
Example_Write() error
Example_Query() error
}
type Client struct {
*firestore.Client
}
func SetupClient() (*Client, error){
return &Client{client}, nil
}
...
In app.go:
import ( "fs" )
type Env struct {
client fs.Datastore
}
client, _ := fs.SetupClient()
env := &Env{client: client}
Error looks like this: 188:14: cannot use client (type *fs.Client) as type fs.Datastore in field value: *fs.Client does not implement fs.Datastore (missing Example_Query method)
Any idea would be appreciated :) Very new to Go so, please bear with me!