title: How to import my own function defined out of main package in Go?
body: <p>I'm pretty new on Go but I'm from the C++ school. I just want to make a project and split the logic into multiple files.</p>
  
  <p>In C++ I just need to put on my <code>main_file.cpp</code> a single</p>
  
  <pre><code>#include "my_own_lib.hpp" 
  </code></pre>
  
  <p>(similar to <code>module.exports</code> and then <code>require('relative/path/to/my-own-lib')</code> in Node.js)</p>
  
  <p>and that's it. In Go I followed the same logic but my result is:</p>
  
  <pre><code>$ go run main.go
  main.go:4:8: open /Users/mt/Documents/Codes/go/src/github.com/mt/Apollo/tst: no such file or directory
  </code></pre>
  
  <p>My files:</p>
  
  <p><strong>main.go</strong></p>
  
  <pre><code>package main
  
  import "fmt"
  import "./tst"
  
  func main() {
      fmt.Println("just testing")
      tst.p()
  }
  </code></pre>
  
  <p><strong>tst.go</strong></p>
  
  <pre><code>package tst
  
  import "fmt"
  
  func p() {
      fmt.Println("ola")
  }
  </code></pre>
  
  <p>Of course my file structure is:</p>
  
  <pre><code>myFolder/
     |- main.go
     |_ tst.go
  </code></pre>
  
  <p>Could someone tell me what is the right way to do this?</p>