title: go build doesn't recognise methods
body: <p>I try to setup a small Golang Microservice for users with Gin and Mongodb.</p>
  <pre class="lang-golang prettyprint-override"><code>package main
  
  import (
      &quot;context&quot;
      &quot;fmt&quot;
      &quot;github.com/wzslr321/artiver/entity&quot;
      &quot;github.com/wzslr321/artiver/settings&quot;
      &quot;go.mongodb.org/mongo-driver/mongo&quot;
      &quot;go.mongodb.org/mongo-driver/mongo/options&quot;
      &quot;log&quot;
      &quot;os&quot;
      &quot;os/signal&quot;
      &quot;syscall&quot;
      &quot;time&quot;
  )
  
  type application struct {
      users *entity.UserCollection
  }
  
  var app *application
  
  func init() {
      initMongo()
  }
  
  func initMongo() {
  
      oc := options.Client().ApplyURI(settings.MongodbSettings.Uri)
  
      client, err := mongo.NewClient(oc)
      if err != nil {
          log.Fatalf(&quot;Error occured while initializing a new mongo client: %v&quot;, err)
      }
  
      ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
      defer cancel()
  
      err = client.Connect(ctx)
      if err != nil {
          log.Fatalf(&quot;Errorr occurred while connecting to a client: %v&quot;, err)
      }
  
      defer func() {
          if err = client.Disconnect(ctx); err != nil {
              panic(err)
          }
      }()
  
      log.Println(&quot;Successfully connected to the database!&quot;)
  
  
      app = &amp;application{
          users: &amp;entity.UserCollection{
              C: client.Database(&quot;artiver&quot;).Collection(&quot;users&quot;),
          },
      }
  }
  
  
  func main() {
  
      router := app.InitRouter()
  
  </code></pre>
  <p>It doesn't show any errors in my IDE ( GoLand ), but when I try to build it I get an error:</p>
  <pre><code># command-line-arguments
  users/cmd/app/main.go:67:15: app.InitRouter undefined (type *application has no field or method InitRouter)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/1zXgM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1zXgM.png" alt="Init router method autocompletion" /></a></p>
  <p>It it easily visible on the image above, that I do have access to such a method. It is defined in the same package.</p>
  <pre class="lang-golang prettyprint-override"><code>package main
  
  import (
      &quot;github.com/gin-gonic/gin&quot;
      cors &quot;github.com/rs/cors/wrapper/gin&quot;
      &quot;net/http&quot;
  )
  
  
  func (app *application) InitRouter() *gin.Engine {
      r := gin.New()
  
      r.Use(gin.Recovery())
      r.Use(cors.Default())
  
      r.GET(&quot;/&quot;, func(ctx *gin.Context) {
          ctx.String(http.StatusOK, &quot;Hello World&quot;)
      })
  
      user := r.Group(&quot;/api/user&quot;)
      {
          user.POST(&quot;/add&quot;, app.CreateUser)
  
      }
  
      return r
  }
  </code></pre>
  <p>I have no idea how am I supposed to fix it and what is done wrong. I'd appreciate any hint about what isn't done correctly.</p>