title: How to install Gin with Golang
body: <p>I'm a newbie on Golang, and I'm trying to use <a href="https://github.com/gin-gonic/gin" rel="noreferrer">Gin</a> to develop a web server on Ubuntu 16.04.</p>
  
  <p>After executing <code>go get -u github.com/gin-gonic/gin</code>, many folders appear at <code>~/go/pkg/mod/github.com/</code>.</p>
  
  <p>Then I try to make an example:</p>
  
  <pre><code>package main
  
  import "github.com/gin-gonic/gin"
  
  func main() {
      r := gin.Default()
      r.GET("/ping", func(c *gin.Context) {
          c.JSON(200, gin.H{
              "message": "pong",
          })
      })
      r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
  }
  </code></pre>
  
  <p>However, <code>go run example.go</code> made the error:</p>
  
  <pre><code>example.go:3:8: cannot find package "github.com/gin-gonic/gin" in any of:
          /usr/local/go/src/github.com/gin-gonic/gin (from $GOROOT)
          /home/zyh/go/src/github.com/gin-gonic/gin (from $GOPATH)
  </code></pre>
  
  <p>In my system, <code>$GOROOT</code> is <code>/usr/local/go/</code> and <code>$GOPATH</code> is <code>~/go/</code>.</p>
  
  <p>How could I solve this problem?</p>