syntagma
syntagma

Reputation: 24344

Accessing Linux network APIs from Go

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?

Upvotes: 0

Views: 364

Answers (1)

David Budworth
David Budworth

Reputation: 11636

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.

Upvotes: 1

Related Questions