title: Debug file other than main.go in VS Code
body: <p>I am writing a CLI in go using VS code editor. I am not able to figure out how to debug a code section.</p>
  
  <p>My directory structure is : </p>
  
  <pre><code>- test
    - main.go
    - cmd
      - login.go
      - root.go
  </code></pre>
  
  <ol>
  <li>I have set breakpoints in login.go but if I run "Start Debugging" in this file, I get error </li>
  </ol>
  
  <pre><code>Can not debug non-main package
  Process exiting with code: 1
  </code></pre>
  
  <ol start="2">
  <li>I tried running debugger in main.go but the debugger won't go to login.go file as I we have not explicitly written <code>test login</code></li>
  </ol>
  
  <pre><code>API server listening at: 127.0.0.1:48423
  A longer description that spans multiple lines and likely contains
  examples and usage of using your application. For example:
  cd .
  Cobra is a CLI library for Go that empowers applications.
  This application is a tool to generate the needed files
  to quickly create a Cobra application.
  
  Usage:
    test [command]
  
  Available Commands:
    help        Help about any command
    login       A brief description of your command
  
  Flags:
        --config string   config file (default is $HOME/.test.yaml)
    -h, --help            help for test
    -t, --toggle          Help message for toggle
  
  Use "test [command] --help" for more information about a command.
  </code></pre>
  
  <ol>
  <li><code>main.go</code> file</li>
  </ol>
  
  <pre><code>package main
  
  import "test/cmd"
  
  func main() {
    cmd.Execute()
  }
  </code></pre>
  
  <ol start="2">
  <li><code>login.go</code> file </li>
  </ol>
  
  <pre><code>package cmd
  
  import (
      "fmt"
      "github.com/spf13/cobra"
  )
  
  // loginCmd represents the login command
  var loginCmd = &amp;cobra.Command{
      Run: func(cmd *cobra.Command, args []string) {
          fmt.Println("login called")
          name, _ := cmd.Flags().GetString("username")
          pwd, _ := cmd.Flags().GetString("password")
          userInfo := name + ":" + pwd
      },
  }
  
  func init() {
      rootCmd.AddCommand(loginCmd)
  
      // Here you will define your flags and configuration settings.
      loginCmd.Flags().StringP("username", "u", "", "Specifies the user")
      loginCmd.Flags().StringP("password", "p", "", "Specifies the password for the user")
      loginCmd.Flags().StringP("manager", "m", "", "Specifies the environement where user wants to login")
  }
  </code></pre>
  
  <ol start="3">
  <li><code>settings.json</code></li>
  </ol>
  
  <pre><code>{
      "go.gopath":"/Users/deepakpatankar/go"
  }
  </code></pre>
  
  <ol start="4">
  <li><code>launch.json</code></li>
  </ol>
  
  <pre><code>{
      // Use IntelliSense to learn about possible attributes.
      // Hover to view descriptions of existing attributes.
      // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
      "version": "0.2.0",
      "configurations": [
          {
              "name": "Launch",
              "type": "go",
              "request": "launch",
              "mode": "auto",
              "program": "${fileDirname}",
              "env": {},
              "args": []
          }
      ]
  }
  </code></pre>
  
  <p>Please guide me how I can see the variable values in debug mode like for variable name. Though using Println is fine, but this source code is part of a bigger project, so I want to see how I can use the debugger ?</p>