version.go 395 B

1234567891011121314151617
  1. package alpm
  2. // #include <alpm.h>
  3. import "C"
  4. import "unsafe"
  5. // VerCmp performs version comparison according to Pacman conventions. Return
  6. // value is <0 if and only if v1 is older than v2.
  7. func VerCmp(v1, v2 string) int {
  8. c1 := C.CString(v1)
  9. c2 := C.CString(v2)
  10. defer C.free(unsafe.Pointer(c1))
  11. defer C.free(unsafe.Pointer(c2))
  12. result := C.alpm_pkg_vercmp(c1, c2)
  13. return int(result)
  14. }