<p>Is there any cross platform solution (native lib) to get the default gateway? golang.org/x/net/route is <a href="https://gist.github.com/abimaelmartell/dcbbff464dc0778165b2dcc5092f90e6">BSD only</a>, so not even Linux and not to mention Windows.</p>
<hr/>**评论:**<br/><br/>jammerlt: <pre><p><a href="https://github.com/jackpal/gateway">https://github.com/jackpal/gateway</a></p></pre>Chohmoh: <pre><p>Thx, didn't found it. I usually prefer not to rely on an exec of a binary which might not even be found and than parse it's ASCII output, but for my use case it's sufficient. Case solved. :)</p></pre>Chuiken: <pre><p><a href="https://github.com/vishvananda/netlink/blob/master/route.go#L35" rel="nofollow">https://github.com/vishvananda/netlink/blob/master/route.go#L35</a></p></pre>Chohmoh: <pre><blockquote>
<p>Netlink is the interface a user-space program in linux uses to communicate with the kernel.</p>
</blockquote>
<p>That's Linux only.</p></pre>hell_0n_wheel: <pre><p>Why do you need to grab the gateway? The network stack abstracts that need away from you...</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传