Skip to content
This repository has been archived by the owner on Apr 2, 2019. It is now read-only.

figure out a way to automatically launch a Go program with main() as a guest instead of requiring editing the Go program to //export something and writing a matching .c stub file #9

Open
eyberg opened this issue Dec 23, 2015 · 3 comments

Comments

@eyberg
Copy link
Member

eyberg commented Dec 23, 2015

figure out a way to automatically launch a Go program with main() as a guest instead of requiring editing the Go program to //export something and writing a matching .c stub file

@yuval-k
Copy link
Contributor

yuval-k commented Mar 6, 2016

You can do it by using two stubs:

mainstub.c:

int kludge_argc = 1;
char *kludge_argv[] = { "foo", 0 };

int main() {
    rump_pub_lwproc_releaselwp(); /* XXX */
    gomaincaller();
}

gomaincaller.go

package main

import "C"

//export gomaincaller
func gomaincaller() {
    main()
}

No program modification is needed to the original go program.
disadvantage is that the need to know where the main package is, as the gomaincaller.go should be in that folder.

@eyberg
Copy link
Member Author

eyberg commented Mar 7, 2016

yeh - def. worth discussing -- @dstrbad - have any opinions on this?

@dstrbad
Copy link
Contributor

dstrbad commented Mar 11, 2016

Looks good, more elegant. Don't see any other options at the moment, a lot to learn on my end :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants