title: How can I automatically add dependency packages to go.mod
body: <p>I have modifed an <a href="https://github.com/josephspurrier/gowebapp" rel="noreferrer">existing github project</a> with dozens of 3rd party imported packages but I kept the basic structure intact, which is like this:</p>
  
  <pre><code>.
  ├── config
  │   ├── config.json
  │   └── mysql.sql
  ├── gowebapp.go
  ├── LICENSE
  ├── README.md
  ├── static
  ├── template
  │   ├── about
  │   │   └── about.tmpl
  │   ├── base.tmpl
  └── vendor
      └── app
          ├── controller
          │   ├── about.go
          │   ├── error.go
          │   ├── index.go
          │   ├── login.go
          │   ├── notepad.go
          │   ├── register.go
          │   └── static.go
          ├── model
          │   ├── model.go
          │   ├── note.go
          │   └── user.go
          ├── route
          │   ├── middleware
          │   │   ├── acl
          │   │   │   └── acl.go
          │   │   ├── httprouterwrapper
          │   │   │   └── httprouterwrapper.go
          │   │   ├── logrequest
          │   │   │   └── logrequest.go
          │   │   └── pprofhandler
          │   │       └── pprofhandler.go
          │   └── route.go
          └── shared
              ├── database
              │   └── database.go
              ├── email
              │   └── email.go
              ├── jsonconfig
              │   └── jsonconfig.go
              ├── passhash
              │   ├── passhash.go
              │   └── passhash_test.go
              ├── recaptcha
              │   └── recaptcha.go
              ├── server
              │   └── server.go
              ├── session
              │   └── session.go
              └── view
                  ├── plugin
                  │   ├── noescape.go
                  │   ├── prettytime.go
                  │   └── taghelper.go
                  └── view.go
  </code></pre>
  
  <p>Now I want to use go modules to make the project portable. </p>
  
  <p>The main.go imports are like:</p>
  
  <pre><code>    package main
  
      import (
      "encoding/json"
      "log"
      "os"
      "runtime"
  
      "app/route"
      "app/shared/database"
      "app/shared/email"
      "app/shared/jsonconfig"
      "app/shared/recaptcha"
      "app/shared/server"
      "app/shared/session"
      "app/shared/view"
      "app/shared/view/plugin"
  )
  </code></pre>
  
  <p>As you can see the code mostly sits in <code>vendor/app</code> folder.</p>
  
  <p>I have added several other packages to that. </p>
  
  <p>The problem is that manually adding the packages to go.mod is so tedious, and after all I may miss some imports. </p>
  
  <p>So I'm wondering if there are some automatic tricks to fetch the dependencies to go.mod? </p>