title: Why are all dependency in go.mod indirect?
body: <p>I initialise a go project by running:</p>
  <pre><code>go mod init firstgo_app
  </code></pre>
  <p>I confirmed the module was created:</p>
  <pre><code>cat go.mod
  module firstgo_app
  
  go 1.18
  </code></pre>
  <p>Then I installed a dependency on github.com/gin-gonic/gin by executing</p>
  <pre><code>get github.com/gin-gonic/gin
  </code></pre>
  <p>after which I viewed the content of <code>go.mod</code> and this time it looks like this:</p>
  <pre><code>cat go.mod
  module firstgo_app
  
  go 1.18
  
  require (
      github.com/gin-contrib/sse v0.1.0 // indirect
      github.com/gin-gonic/gin v1.7.7 // indirect
      github.com/go-playground/locales v0.13.0 // indirect
      github.com/go-playground/universal-translator v0.17.0 // indirect
      github.com/go-playground/validator/v10 v10.4.1 // indirect
      github.com/golang/protobuf v1.3.3 // indirect
      github.com/json-iterator/go v1.1.9 // indirect
      github.com/leodido/go-urn v1.2.0 // indirect
      github.com/mattn/go-isatty v0.0.12 // indirect
      github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
      github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 // indirect
      github.com/ugorji/go/codec v1.1.7 // indirect
      golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
      golang.org/x/sys v0.0.0-20200116001909-b77594299b42 // indirect
      gopkg.in/yaml.v2 v2.2.8 // indirect
  )
  </code></pre>
  <p>What I do not get is the fact that all the dependency has been tagged as <em>indirect</em>. My understanding is that it is only transitive dependency that are tagged <em>indirect</em> but the dependency I directly depend upon should not be tagged as such. That is <code>github.com/gin-gonic/gin v1.7.7 // indirect</code> should not have the <em>indirect</em> tag since this is the dependency I specifically downloaded.</p>
  <p>I thought this was the case because I am not directly using the dependency, so I recreated the module again but also created a <code>main.go</code> file where I explicitly depend on <code>gonic/gin</code>:</p>
  <pre><code>cat main.go
  package main
  import &quot;github.com/gin-gonic/gin&quot;
  func main() {
          r := gin.Default()
          r.GET(&quot;/ping&quot;, func(c *gin.Context) {
                  c.JSON(200, gin.H{
                          &quot;message&quot;: &quot;pong&quot;,
                  })
          })
          r.Run() // listen and serve on 0.0.0.0:8080
  }
  </code></pre>
  <p>When I try to build it fails with:</p>
  <pre><code>go build
  main.go:2:8: no required module provides package github.com/gin-gonic/gin; to add it:
      go get github.com/gin-gonic/gin
  </code></pre>
  <p>but when I run <code>go get github.com/gin-gonic/gin</code> and then build, all the dependency in <code>go.mod</code> are still tagged indirect.</p>
  <p>So what gives? What am I missing here? Or do I understand the <em>indirect</em> wrongly?</p>