Golang 1.15.7: Return of a Shared library using *C.char

Asked

Viewed 42 times

2

I’m trying to create a Shared library in go, but the return (*C.char) always comes back empty:

How to do to return right?

package main
import (
    "C"
    "fmt"
)
//export Upper
func Upper(palavra *C.char, retorno *C.char, size *int) int {
    fmt.Println(C.GoString(palavra))
    retorno = C.CString(strings.ToUpper(str1))
    *size = int(len(palavra))
    return 0
}
func main() {}
  • 1

    Shouldn’t be **C.char and then do: *retorno = C.CString(strings.ToUpper(str1))?

  • Inkeliz, I tested as you suggested, but even though now I get a return, the return is coming wrong(dirty). I also tried to leave *C.char and putting *retorno = *C.CString(strings.ToUpper(str1))... but in this way only changes the first position.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.