I've method
which I want to provide some interface to make it more easier to test
This is the function
File A
func readFile(s source) ([]byte, error) {
p := fs.GetPath()
file, err := ioutil.ReadFile(p + "/" + s.path + "/" + "rts.yaml")
if err != nil {
return yamlFile, fmt.Errorf("erro reading file : %s", err.Error())
}
return file, err
}
Now I add for it struct
type source struct{
path string
}
And the interface that the readFile
is implementing
type fileReader interface {
readFile(path string) ([]byte, error)
}
And now I need to call this function from another file but Im getting error while doing this
File B
type source struct {
path string
}
a := source{}
yamlFile, err := readFile(a)
what am I missing here ?