main() in Go not running after C import

102 views Asked by At

I am trying to import some C code for use in my Golang application. I am really new to Go so I most likely have done something stupid here:

I have one file main.go in the main directory and yolo.go in the /yolo subdirectory along with all my C code.

yolo.go

package yolo

import "C"

func Vals() string {
    return "Good to go!"
}

main.go

package main

import "fmt"
import "./yolo"

func main() {
    fmt.Printf(yolo.Vals())
    fmt.Printf("test")
}

This seems to compile fine - but none of the code in the main() function in main.go runs - no output is given, but no errors are either. If I forget about the import "C" everything runs just fine and I get the output I expect. What am I doing wrong?

0

There are 0 answers