title: importing custom package in Go
body: <p>I <a href="https://stackoverflow.com/questions/15049903/how-to-use-custom-packages-in-golang">checked out this answer</a> and for some reason either I was unable to comprehend properly or it didn't work</p>
  
  <p>Also, Before I start, I got that How we can do it with github but I want to try it without github</p>
  
  <p>To start let's say I have a main.go file</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "math"
      "subpack"
  )
  
  //You Import packages without using comma in Go, rather space or new line
  //In VS Code, if you use aren't using the package and run then it will automatically removie it
  
  func main() {
      fmt.Println("hello world")
      //We use math.Floor to round the nunmber
      fmt.Println(math.Floor(2.7))
      fmt.Println(math.Sqrt(16))
      fmt.Println(subpack.Reverse)
  }
  </code></pre>
  
  <p>Notice  <code>subpack</code> here, it is the custom package I made. The subpack exsist like this </p>
  
  <p><a href="https://i.stack.imgur.com/TTfXZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TTfXZ.png" alt="enter image description here"></a></p>
  
  <p>And contains the following code</p>
  
  <pre><code>package subpack
  
  //If we make this in the same root level of our main it will throw an error
  
  func Reverse(s string) string {
      runes := []rune(s)
      for i, j := 0, len(runes)-1; i &lt; j; i, j = i+1, j-1 {
          runes[i], runes[j] = runes[j], runes[i]
      }
      return string(runes)
  }
  </code></pre>
  
  <p>running our go is throwing following error </p>
  
  <pre><code>cannot find package "subpack" in any of:
          /usr/local/go/src/subpack (from $GOROOT)
          /Users/anilbhatia/go/src/subpack (from $GOPATH)
  </code></pre>
  
  <p><strong>Question:</strong> Is it possible and if yes, How to use custom package without github and without making it in the GO main folder rather by simply referencing the folder containing our <code>go</code> file from the directory we are working.</p>