dpka7974 2017-06-13 04:46
浏览 40
已采纳

添加gokogiri依赖关系会导致`Killed:9`退出

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.

  • 写回答

1条回答 默认 最新

  • duanjieyi6582 2017-06-13 13:47
    关注

    According to similar issue, and also in Golang issue #19734, cgo command broken on darwin after performing c tool-chain (Xcode 8.3) update from Apple.

    The solution: upgrade to go1.8.1 or above or add -ldflags=-s to build or test command, e.g. go build -ldflags=-s.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来