func main() { py.Initialize() methods := []py.Method{ {"example", example, "example function"}, } m, err := py.InitModule("example", methods) if err != nil { fmt.Printf("ERROR: %s\n", err) os.Exit(1) } c, err := exampleClass.Create() if err != nil { fmt.Printf("ERROR: %s\n", err) os.Exit(1) } err = m.AddObject("ExampleClass", c) if err != nil { fmt.Printf("ERROR: %s\n", err) os.Exit(1) } py.Main(os.Args) }
func setupShModule() error { methods := []py.Method{ {"tokenise", pyTokenise, "tokenise the given string"}, {"run", pyRun, "run the given command"}, } shMod, err := py.InitModule("sh", methods) if err != nil { return err } mod, err := py.InitModule("sh.__cmds__", []py.Method{}) if err != nil { return err } err = shMod.AddObject("__cmds__", mod) if err != nil { return err } return nil }