I am creating three applications which are very similar to each other but each will apply different logic. I am not sure how to best structure it to avoid repeating code.
All applications have the following in common: - read and parse config - setup SQL database connection - gather stats - read from STDIN
Each application will apply different logic to the data read from STDIN.
Would this be considered acceptable? Put all common code in main.go then build as "go build -o bin/app1 main.go app1.go" and so on - pulling in only the app specific logic for each binary to build?
main.go:
func main() {
// db connection
// stats worker
// read from stdin
proccessLine(line)
}
app1.go:
func processLine(line string) {
// logic for app 1
}
app2.go:
func processLine(line string) {
// logic for app 2
}
etc.