Differences between revisions 7 and 8
Revision 7 as of 2016-10-27 13:49:12
Size: 1368
Editor: mnovakovic
Comment:
Revision 8 as of 2016-10-27 13:52:37
Size: 1367
Editor: mnovakovic
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:

Go has built in support for swig but it requiers manual setup and compiliing takes time. A better soultion is to [[https://golang.org/cmd/cgo/| cgo]] it will link against local sysrepo binaries and is esaire to setup.
The path to sysrepo binaries and headers can be manualy setup with editing [[https://github.com/sysrepo/sysrepo/blob/devel/swig/golang/examples/application_changes_example/golang_application_changes_example.go#L30 | #cgo LDFLAGS: -lsysrepo]] which needs to be before [[ https://github.com/sysrepo/sysrepo/blob/devel/swig/golang/examples/application_changes_example/golang_application_changes_example.go#L35| import "C"]] line. The same aplies to the flag for headers.
Go has built in support for swig but it requires manual setup and compiling takes time. A better solution is to [[https://golang.org/cmd/cgo/| cgo]] it will link against local sysrepo binaries and is easier to setup.
The path to sysrepo binaries and headers can be manually setup with editing [[https://github.com/sysrepo/sysrepo/blob/devel/swig/golang/examples/application_changes_example/golang_application_changes_example.go#L30 | #cgo LDFLAGS: -lsysrepo]] which needs to be before [[ https://github.com/sysrepo/sysrepo/blob/devel/swig/golang/examples/application_changes_example/golang_application_changes_example.go#L35| import "C"]] line. The same applies to the flag for headers.

Sysrepo Go bindings

Go has built in support for swig but it requires manual setup and compiling takes time. A better solution is to cgo it will link against local sysrepo binaries and is easier to setup. The path to sysrepo binaries and headers can be manually setup with editing #cgo LDFLAGS: -lsysrepo which needs to be before import "C" line. The same applies to the flag for headers.

From the docker container sysrepo/sysrepo-netopeer2:devel_20161027 you can use the Go examples.

The code example used can be found here.

You can run the Go examples with:

cd /opt/dev/sysrepo
sysrepod
netopeer2-server
cd swig/golang/examples

cd application_changes_example
go build
./application_changes_example

You can watch the process in the asciinema video:

https://asciinema.org/a/90767

bindings/go (last edited 2016-10-27 13:52:37 by mnovakovic)