def __init__(self, m, name, sinfo): m.stmt("/* structure") cm = GoModule() m.stmt(cm) cm.stmt(name) self.cm_map = {sinfo["jsonname"]: cm} m.stmt("*/")
from prestring.go import GoModule m = GoModule() with m.import_group() as im: im("fmt") with m.func("main"): m.stmt('fmt.Println("Hello, 世界")') print(m)
from prestring import PreString from prestring.go import GoModule m = GoModule() p = PreString("") m.stmt("foo") m.stmt(p) m.stmt("bar") p.body.append("*inner*") print(m)