title: How can I "go run" a project with multiple files in the main package?
body: <p>I have a single file in the <code>main</code> package called <code>main.go</code>. Because the code isn't reusable I want to separate part of the code in a different file but in the same package.</p>
  <p>How do I split the contents of <code>main.go</code> into multiple files without creating a separate package?</p>
  <p>I want a directory structure like this:</p>
  <pre class="lang-sh prettyprint-override"><code>ls foo
  
  # output:
  main.go
  bar.go
  </code></pre>
  <ul>
  <li>File: <code>bar.go</code></li>
  </ul>
  <pre class="lang-golang prettyprint-override"><code>package main
  
  import &quot;fmt&quot;
  
  func Bar() {
    fmt.Println(&quot;Bar&quot;)
  }
  </code></pre>
  <ul>
  <li>File: <code>main.go</code></li>
  </ul>
  <pre class="lang-golang prettyprint-override"><code>package main
  
  func main() {
    Bar()
  }
  </code></pre>
  <p>When I run <code>go run main.go</code>, it gives me:</p>
  <pre class="lang-sh prettyprint-override"><code># command-line-arguments
  ./main.go:4:2: undefined: Bar
  </code></pre>