I have a function in Go:
func login(user *C.char) *C.char {
cstr := C.CString("Hello World")
defer C.free(unsafe.Pointer(cstr))
return cstr
}
My ruby code as below
module GoLib
extend FFI::Library
ffi_lib './golib.so'
attach_function :login, [:string], :string
end
GoLib.login("User1") #=> "p\x9A\xA0\xDB\x16V"
it does not return as ruby string. How to I fix this?