August 2019
Beginner to intermediate
798 pages
17h 2m
English
This subsection will present you with the code of the Go package that will be used in a C program. The name of the Go package needs to be main but its filename can be anything you want; in this case, the filename will be usedByC.go and it will be presented in three parts.
The first part of the code of the Go package is next:
package main
import "C"
import (
"fmt"
)
As I said before, it is mandatory to name the Go package main. You will also need to import the C package in your Go code.
The second part comes with the following Go code:
//export PrintMessage func PrintMessage() { fmt.Println("A Go function!") } ...Read now
Unlock full access