Skip to content

Instantly share code, notes, and snippets.

@todd
Last active August 29, 2015 14:00
Show Gist options
  • Save todd/477bea7bc30ae91f1fcd to your computer and use it in GitHub Desktop.
Save todd/477bea7bc30ae91f1fcd to your computer and use it in GitHub Desktop.
Go-libmpdclient Binding Test
package main
/*
#cgo pkg-config: libmpdclient
#include <stdlib.h>
#include <mpd/client.h>
*/
import "C"
import (
"unsafe"
"fmt"
)
func main() {
host := C.CString("127.0.0.1")
fmt.Println(host)
conn := C.mpd_connection_new(host, 0, 0)
fmt.Println(C.mpd_connection_get_error(conn))
status := C.mpd_run_status(conn)
song_id := C.mpd_status_get_song_id(status)
fmt.Println(int(song_id))
C.mpd_status_free(status)
C.mpd_connection_free(conn)
C.free(unsafe.Pointer(host))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment