title: How to structure Go application to produce multiple binaries?
body: <p>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. </p>
  
  <p>All applications have the following in common:
  - read and parse config
  - setup SQL database connection
  - gather stats
  - read from STDIN</p>
  
  <p>Each application will apply different logic to the data read from STDIN. </p>
  
  <p>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?</p>
  
  <p>main.go:</p>
  
  <pre><code>func main() {
      // db connection
      // stats worker
      // read from stdin
  
      proccessLine(line)
  }
  </code></pre>
  
  <p>app1.go:</p>
  
  <pre><code>func processLine(line string) {
      // logic for app 1
  }
  </code></pre>
  
  <p>app2.go:</p>
  
  <pre><code>func processLine(line string) {
      // logic for app 2
  }
  </code></pre>
  
  <p>etc.</p>