doucheng1063 2015-06-23 08:36 采纳率: 100%
浏览 140
已采纳

从Go访问Linux网络API

I would like to write a simple utility program in Go to manage network (wired and wireless) connections on Linux, a software similar to NetworkManager and WICD.

What would be the correct way to access Linux APIs in Go? Should I use C bindings and native Linux API call, execute a command and parse its output or maybe there is some library designed to do what I want to do?

  • 写回答

1条回答 默认 最新

  • dongzhuo5425 2015-06-23 11:58
    关注

    You very likely want to use cgo as it's really easy to call any C API

    An added benefit is that C APIs are usually pretty stable over time as the library creators almost always opt for a new function rather than break the API of an existing one.

    Running command line tools and parsing output is error prone as the software you call will most likely change it's output overtime, breaking your parsers.

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

报告相同问题?

悬赏问题

  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本