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.

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

报告相同问题?

悬赏问题

  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R
  • ¥15 在线请求openmv与pixhawk 实现实时目标跟踪的具体通讯方法
  • ¥15 八路抢答器设计出现故障
  • ¥15 opencv 无法读取视频
  • ¥15 用matlab 实现通信仿真
  • ¥15 按键修改电子时钟,C51单片机
  • ¥60 Java中实现如何实现张量类,并用于图像处理(不运用其他科学计算库和图像处理库))
  • ¥20 5037端口被adb自己占了