mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Adds documentation and reformats names
This commit is contained in:
@ -7,6 +7,13 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ByteSlice builds a byte Slice over a C pointer returned by a
|
||||||
|
// C function.
|
||||||
|
// The C pointer has to be passed as an unsafe.Pointer
|
||||||
|
// and the size of the pointed memery area has to be
|
||||||
|
// indicated through the size parameter.
|
||||||
|
// No memory allocation is done by that function. It
|
||||||
|
// just consists in mapping a Go object too a C one.
|
||||||
func ByteSlice(pointer unsafe.Pointer, size int) []byte {
|
func ByteSlice(pointer unsafe.Pointer, size int) []byte {
|
||||||
var s []byte
|
var s []byte
|
||||||
|
|
||||||
|
@ -5,14 +5,21 @@ import (
|
|||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// NotAnInteger defines a new type of Error : "NotAnInteger"
|
||||||
type NotAnInteger struct {
|
type NotAnInteger struct {
|
||||||
message string
|
message string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Error() retreives the error message associated to the "NotAnInteger"
|
||||||
|
// error. Tha addition of that Error message make the "NotAnInteger"
|
||||||
|
// complying with the error interface
|
||||||
func (m *NotAnInteger) Error() string {
|
func (m *NotAnInteger) Error() string {
|
||||||
return m.message
|
return m.message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InterfaceToInt converts a interface{} to an integer value if possible.
|
||||||
|
// If not a "NotAnInteger" error is returned via the err
|
||||||
|
// return value and val is set to 0.
|
||||||
func InterfaceToInt(i interface{}) (val int, err error) {
|
func InterfaceToInt(i interface{}) (val int, err error) {
|
||||||
|
|
||||||
err = nil
|
err = nil
|
||||||
@ -47,6 +54,7 @@ func InterfaceToInt(i interface{}) (val int, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CopyMap makes a deep copy of a map[string]interface{}.
|
||||||
func CopyMap(dest, src map[string]interface{}) {
|
func CopyMap(dest, src map[string]interface{}) {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
gob.NewEncoder(buf).Encode(src)
|
gob.NewEncoder(buf).Encode(src)
|
||||||
|
Reference in New Issue
Block a user