Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "C"
- "fmt"
- )
- func main() {}
- //export Test
- func Test(str *C.char) {
- fmt.Println("Hello from within Go")
- fmt.Println(fmt.Sprintf("A message from Go: %s", C.GoString(str)))
- }
- using System;
- using System.Runtime.InteropServices;
- namespace test
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Hello");
- Console.WriteLine(GoFunctions.Test("world"));
- Console.WriteLine("Goodbye.");
- }
- }
- static class GoFunctions
- {
- [DllImport(@<path to test.dll>, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
- public static extern string Test(GoString str);
- }
- }
- go build -buildmode=c-shared -o test.dll <path to go file>
- Hello from within Go
- A message from Go: w
- panic: runtime error: growslice: cap out of range
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement