I want to create a module library where a files can be added and will be part of my binary.
For example, in my package main
I have:
type InitFunc func(params DriverParams) (Driver, error)
func Register(name string, f InitFunc) {
}
Then I would like someone to add a file in the modules directory that calls Register()
.
Subsequently my main package will call all the functions that have registered themselves.
This way, my main package has no prior knowledge of the modules that will be added.
How do I accomplish this in golang?