Hi, I am facing the following issue:
I have a GO code that has to be called from the C code: var field_mappings map[string]string = map[string]string{ " A": "a", "B": "b", "C": "c", "D": "d"} //export CallBack func CallBack(key *C.char, value *C.char, value_len C.size_t){ if remap, ok := field_mappings[key]; ok { fmt.Println(key, remap) } } I am passing this callback method to the C function func ReloadPatternDB(opts Y){ x := C.CString(opts.x) C.reload_pattern_db(x, CallBack); } int reload_pattern_db(const gchar* filename, key_value_cb cb) { // } Following is my C header file: #ifndef _TEST_H_ #define _TEST_H_ #include <stdlib.h> typedef void (*key_value_cb)(const char* key, const char* value, size_t value_len); int initialize_engine(const char* filename, const char* module_path, key_value_cb cb); int reload_pattern_db(const char* filename, key_value_cb cb); void match(const char* pattern, size_t pattern_len, const char* program, size_t program_len); #endif When I compile the GO code I am getting the following error: # command-line-arguments ./main.go:80:32: cannot use key (type *_Ctype_char) as type string in map index ./main.go:91:21: cannot use CallBack (type func(*_Ctype_char, *_Ctype_char, _Ctype_ulong)) as type *[0]byte in argument to _Cfunc_reload_pattern_db ./main.go:143:21: cannot use CallBack (type func(*_Ctype_char, *_Ctype_char, _Ctype_ulong)) as type *[0]byte in argument to I am new to GO and CGO.Can someone please point out the error and help me out ? Thanks -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.