clean up readme, add example

This commit is contained in:
Ross Kinder
2015-10-06 10:18:59 -04:00
parent 9cc696353d
commit 109617ef26
3 changed files with 73 additions and 45 deletions

View File

@@ -18,6 +18,10 @@ import "C"
// #include "libxml/parser.h"
// #include "libxml/parserInternals.h"
// #include "libxml/xmlmemory.h"
// // Macro wrapper function
// static inline void MY_xmlFree(void *p) {
// xmlFree(p);
// }
import "C"
func init() {
@@ -81,7 +85,7 @@ func dumpDoc(doc *C.xmlDoc) string {
var bufferSize C.int
C.xmlDocDumpMemory(doc, &buffer, &bufferSize)
rv := C.GoStringN((*C.char)(unsafe.Pointer(buffer)), bufferSize)
C.xmlMemFree(unsafe.Pointer(buffer))
C.MY_xmlFree(unsafe.Pointer(buffer))
return rv
}
@@ -120,6 +124,7 @@ func Sign(key []byte, docStr string) (string, error) {
return dumpDoc(doc), nil
}
// ErrVerificationFailed is returned from Verify when the signature is incorrect
var ErrVerificationFailed = errors.New("signature verification failed")
const (