title: Debug GO with Delve on my Mac: "combining dwarf failed: Unknown load command 0x32"
body: <p>The IDE is Visual Studio Code. Here is the log when I switching on the debugger:</p>
  
  <pre><code># _/Users/leon/Documents/Projects/GoLang/TutorialLearningGoForWebDevelopment
  /usr/local/go/pkg/tool/darwin_amd64/link: /usr/local/go/pkg/tool/darwin_amd64/link: combining dwarf failed: Unknown load command 0x32 (50)
  exit status 2
  Process exiting with code: 1
  </code></pre>
  
  <p>Go version:</p>
  
  <pre><code>go version go1.10.3 darwin/amd64
  </code></pre>
  
  <p>MacOS version:</p>
  
  <pre><code>Mojave Version 10.14 Beta (18A353d)
  </code></pre>
  
  <p>Delve version:</p>
  
  <pre><code>Delve Debugger
  Version: 1.0.0
  Build: $Id: c98a142125d0b17bb11ec0513bde346229b5f533 $
  </code></pre>
  
  <p>Visual Studio Code Version:</p>
  
  <pre><code>  Version 1.26.0-insider (1.26.0-insider)
  </code></pre>
  
  <p>The <code>launch.json</code> was nearly automatically generated, with port changed only:</p>
  
  <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": "debug",
              "remotePath": "",
              "port": 8080,
              "host": "127.0.0.1",
              "program": "${fileDirname}",
              "env": {},
              "args": [],
              "showLog": true,
              "trace": "verbose"
          }
      ]
  }
  </code></pre>
  
  <p>Finding out some similar problem threads <a href="https://github.com/golang/go/issues/25908" rel="noreferrer">here</a>, I did not find a solution.<br/>
  I also installed <code>go1.11beta3</code>, but I do not know how to make it default in terms of VSCode debugging.<br/><br/><br/></p>
  
  <p>One more accurate description of the symptom:<br/>
  the error was NOT caused on <code>Delve</code> side, but originated from the very first line of the <code>go</code> program: <code>package main</code></p>
  
  <p>Just in case some one might need to read the code, I am including the whole file below:</p>
  
  <pre><code>package main
  
  import (
      "database/sql"
      "encoding/json"
      "fmt"
      "html/template"
      "io/ioutil"
      "net/http"
      "net/url"
  
      _ "github.com/mattn/go-sqlite3"
  
      "encoding/xml"
  )
  
  type Page struct {
      Name     string
      DBStatus bool
  }
  
  type SearchResult struct {
      Title  string `xml:"title,attr"`
      Author string `xml:"author,attr"`
      Year   string `xml:"hyr,attr"`
      ID     string `xml:"owi,attr"`
  }
  
  type ClassifySearchResponse struct {
      Results []SearchResult `xml:"works&gt;work"`
  }
  
  type ClassifyBookResponse struct {
      BookData struct {
          Title  string `xml:"title,attr"`
          Author string `xml:"author,attr"`
          ID     string `xml:"owi,attr"`
      } `xml:"work"`
      Classification struct {
          MostPopular string `xml:"sft,attr"`
      } `xml:"recommendations&gt;ddc&gt;mostPopular"`
  }
  
  func main() {
      templates := template.Must(template.ParseFiles("templates/index.html"))
  
      db, _ := sql.Open("sqlite3", "dev_golang.db")
  
      http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
          p := Page{Name: "Gopher"}
          if name := r.FormValue("name"); name != "" {
              p.Name = name
          }
          p.DBStatus = db.Ping() == nil
  
          if err := templates.ExecuteTemplate(w, "index.html", p); err != nil {
              http.Error(w, err.Error(), http.StatusInternalServerError)
          }
      })
  
      http.HandleFunc("/search", func(w http.ResponseWriter, r *http.Request) {
          var results []SearchResult
          var err error
  
          if results, err = search(r.FormValue("search")); err != nil {
              http.Error(w, err.Error(), http.StatusInternalServerError)
          }
  
          encoder := json.NewEncoder(w)
          if err := encoder.Encode(results); err != nil {
              http.Error(w, err.Error(), http.StatusInternalServerError)
          }
      })
  
      http.HandleFunc("/books/add", func(w http.ResponseWriter, r *http.Request) {
          var book ClassifyBookResponse
          var err error
  
          if book, err = find(r.FormValue("id")); err != nil {
              http.Error(w, err.Error(), http.StatusInternalServerError)
          }
  
          if err = db.Ping(); err != nil {
              http.Error(w, err.Error(), http.StatusInternalServerError)
          }
  
          _, err = db.Exec("insert into books (pk, title, author, id, classification) values (?,?,?,?,?)",
              nil,
              book.BookData.Title,
              book.BookData.Author,
              book.BookData.Author,
              book.BookData.ID,
              book.Classification.MostPopular)
  
          if err != nil {
              http.Error(w, err.Error(), http.StatusInternalServerError)
          }
      })
  
      fmt.Println(http.ListenAndServe(":8080", nil))
  }
  
  func find(id string) (ClassifyBookResponse, error) {
      var c ClassifyBookResponse
      body, err := classifyAPI("http://classify.oclc.org/classify2/Classify?summary=true&amp;owi=" + url.QueryEscape(id))
  
      if err != nil {
          return ClassifyBookResponse{}, err
      }
  
      err = xml.Unmarshal(body, &amp;c)
      return c, err
  }
  
  func search(query string) ([]SearchResult, error) {
      var c ClassifySearchResponse
      fmt.Println("query, search(): " + query)
      body, err := classifyAPI("http://classify.oclc.org/classify2/Classify?summary=true&amp;title=" + url.QueryEscape(query))
  
      if err != nil {
          fmt.Println(err.Error())
          return []SearchResult{}, err
      }
  
      err = xml.Unmarshal(body, &amp;c)
      fmt.Println(c.Results)
      return c.Results, err
  }
  
  func classifyAPI(url string) ([]byte, error) {
      var resp *http.Response
      var err error
  
      if resp, err = http.Get(url); err != nil {
          return []byte{}, err
      }
  
      defer resp.Body.Close()
  
      return ioutil.ReadAll(resp.Body)
  }
  </code></pre>