Last active
September 15, 2018 16:52
-
-
Save mdeous/5f25b92be52a105e87e20cd199656f23 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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