The environment I am using is go1.8 on MacOS Sierra.
The code:
package main
import (
    "fmt"
    "io/ioutil"
    "github.com/moovweb/gokogiri"
    "github.com/moovweb/gokogiri/xpath"
)
func main() {
    fmt.Println("hello world")
    b, _ := ioutil.ReadFile("x.xml")
    fmt.Println(string(b))
    doc, _ := gokogiri.ParseXml(b)
    compiled := xpath.Compile("/path/to/node")
    ss, _ := doc.Root().Search(compiled)
    for _, s := range ss {
        fmt.Println(s.Content())
    }
}
After I build and run:
$ ./hello-world
Killed: 9
Even the hello world message is not printed. Later on, on investigating the gokogiri README, I saw instructions on installing libxml2. So I did brew install libxml2 and tried, and that also did not fix the issue.
                        
According to similar issue, and also in
Golang issue #19734,cgocommand broken on darwin after performing c tool-chain (Xcode 8.3) update from Apple.The solution:
upgrade to go1.8.1 or aboveor add-ldflags=-stobuildortestcommand, e.g.go build -ldflags=-s.