gorump
gorump copied to clipboard
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
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
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.
yeh - def. worth discussing -- @dstrbad - have any opinions on this?
Looks good, more elegant. Don't see any other options at the moment, a lot to learn on my end :)