-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdel.go
More file actions
36 lines (32 loc) · 667 Bytes
/
del.go
File metadata and controls
36 lines (32 loc) · 667 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
/*
#include <stdlib.h>
struct userInfo {
char* info;
};
*/
import "C"
import (
"fmt"
"unsafe"
)
// Generates a data object for Python.
//
//export getUserInfo
func getUserInfo(cname *C.char) C.struct_userInfo {
var result C.struct_userInfo
name := C.GoString(cname)
result.info = C.CString(
fmt.Sprintf("User %q has %v letters in their name",
name, len(name)))
return result
}
// Deallocates a data object.
//
//export delUserInfo
func delUserInfo(info C.struct_userInfo) {
// This print is only for educational purposes.
fmt.Printf("Freeing user info: %s\n", C.GoString(info.info))
C.free(unsafe.Pointer(info.info))
}
func main() {}