title: How to compare HTML markup in Golang?
body: <p>I'm trying to come up with a test suite which checks HTML fragments/files are canonically equivalent to one another. I was surprised to see that if I parse the same string or file, the <a href="https://godoc.org/golang.org/x/net/html#Node" rel="nofollow">https://godoc.org/golang.org/x/net/html#Node</a> was comparing as different. What am I missing?</p>
  
  <p>Hopefully this demonstrates the issue:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "strings"
  
      "golang.org/x/net/html"
  )
  
  func main() {
      s := `&lt;h1&gt;
      test
      &lt;/h1&gt;&lt;p&gt;foo&lt;/p&gt;`
      // s2 := `&lt;h1&gt;test&lt;/h1&gt;&lt;p&gt;foo&lt;/p&gt;`
  
      doc, _ := html.Parse(strings.NewReader(s))
      doc2, _ := html.Parse(strings.NewReader(s))
  
      if doc == doc2 {
          fmt.Println("HTML is the same") // Expected this
      } else {
          fmt.Println("HTML is not the same") // Got this
      }
  }
  </code></pre>
  
  <p><strong>HTML is not the same</strong></p>