Skip to content

Instantly share code, notes, and snippets.

@mdeous
Last active September 15, 2018 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdeous/5f25b92be52a105e87e20cd199656f23 to your computer and use it in GitHub Desktop.
Save mdeous/5f25b92be52a105e87e20cd199656f23 to your computer and use it in GitHub Desktop.
type Collector interface {
Collect()
}
type LogsCollector struct {
output string
}
func (lc *LogsCollector) Collect() {
// do stuff
}
func NewLogCollector(outputFile string) *LogsCollector {
c = new(LogsCollector)
c.output = outputFile
return c
}
func main() {
var collectorBuilders = map[string]func(outputFile string) *Collector {
"logs": NewLogsCollector,
"files": NewFilesCollector,
}
var outputFile string
for collectorType, collectorBuilder := range collectorBuilders {
outputFile = fmt.Sprintf("%s.csv", collectorType)
c := collectorBuilder(outputFile)
go c.Collect()
}
}
// ERROR: cannot use "goir/internal/collectors".NewFilesCollector (type func(string) *"goir/internal/collectors".FilesCollector) as type func(string) *"goir/internal/collectors".Collector in map value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment