title: How to import local packages when using Go modules
body: <p>I wish to create a large project, so I need to create some kind of folder structure. I am quite new to Go, but, as I understand, the way to do it is to create packages, right? I am using Go modules, I have tried many different solutions found here and on Google, but none of them seem to work for me.</p>
  
  <p>All I want to for now, is import exported function from example.go file into main.go</p>
  
  <p>Folder structure is as follows:</p>
  
  <pre><code>client
  example
  ---example.go
  go.mod
  go.sum
  main.go
  </code></pre>
  
  <ol>
  <li>I have created module file with go mod init, see the first code snippet below</li>
  <li>Second code snippet shows how the header of main.go looks like</li>
  <li>Third snippet is the package with the function I want to import</li>
  </ol>
  
  <pre><code>    module exampleapp
      go 1.12
      require (
          github.com/gin-gonic/contrib v0.0.0-20190408155029-b5986969cb50
          github.com/gin-gonic/gin v1.4.0
      )
  
  </code></pre>
  
  <pre><code>package main
  import (
      "net/http"
      "exampleapp/example"
  )
  </code></pre>
  
  <pre><code>    package example
      import (
          "net/http"
          "github.com/gin-gonic/gin"
      )
  
      func GetAllEmployees(c *gin.Context) {
          c.JSON(http.StatusOK, gin.H{
              "message": "pong",
          })
      }
  </code></pre>
  
  <p>For the most part, when I try to add package in main.go, VSCode automatically removes the line and in the main function says that GetAllEmployees is not defined. I managed to catch error package before the package is removed, it says - <pre>"imported and not used: "exampleapp/example"</pre>
  Am I wrong to use "exampleapp/example" module name exampleapp here? I tried without the exampleapp and "./example/example", but then I get an error that says it cannot find module for path.</p>
  
  <p>Help would be highly appreciated, as I have been stuck on this for quite some time and can't figure out, what am I missing here.</p>