Goland declares

I am trying to get data from a DLL compiled in golang, i have two functions, one that returns an integer and one a string (The local IP address) .

soft Declare function GetOutboundIP Lib “mydll.dll” () as Cstring
var result as string=GetOutboundIP()
system.debuglog result
**Code never gets here Xojo exits

The problem I have is Xojo exits when I call the fuction?
Anyone have any ideas?, I can pass and read integers ok. Is there any document that shows you how to convert the data from a DLL to Xojo?

Dave

What happens if you use a Ptr instead of a CString?

soft Declare function GetOutboundIP Lib "mydll.dll" () as Ptr
var result as MemoryBlock=GetOutboundIP()
If result <> Nil Then
  system.debuglog result.CString(0)
Else
  system.debuglog "Return value is null"
End If

This works ok:

package main
import "C"

//export HelloWorld
func HelloWorld() *C.char{
    return C.CString("Hello World!")
}

func main() {    
// Need a main function to make CGO compile package as C shared library
}
Declare Function HelloWorld Lib "C:\Users\Julian\Documents\Go\TestDLL\TestDLL.dll" () As CString
Dim s As CString = HelloWorld()
system.DebugLog(s)

Excelent! it works. Now to figure out arrays slices etc. Is there any documentation anywhere that explains all this?
Dave

Here’s an interesting question, when goland is running inside a dll declared by xojo, can it use all the threads / processors in a machine, as if its native?

Documentation - The Go Programming Language ?

I can’t see why not as long as you do things correctly. I know nothing about go so I can’t help I’m afraid. See here for more info A Tour of Go

Yeah, I know go and its pretty good at sharing load over CPU if you do it correctly, its just how does Xojo decide what it uses in place of go data types, in fact it looks more like the DLL uses C data types.