Documentation
¶
Index ¶
- Variables
- func Call(name string) *icall
- func Const() *iconst
- func For(judge any) *ifor
- func Function(name string) *ifunction
- func If(judge any) *iif
- func Import() *iimport
- func Interface(name string) *iinterface
- func LineComment(content string, args ...any) *istring
- func Lit(value any) *lit
- func NewGroup() *group
- func Package(name string) *ipackage
- func Return(node ...any) *ireturn
- func String(format string, args ...any) *istring
- func Switch(judge any) *iswitch
- func Type(name string, typ any) *itype
- func TypeAlias(name string, typ any) *itype
- func Value(typ string) *ivalue
- func Var() *ivar
- type Generator
- type IStruct
- type Node
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var S = String
S is an alias to String. TODO: can we find a new name for this?
Functions ¶
func Function ¶
func Function(name string) *ifunction
Function represent both method and function in Go.
NOTES ¶
If `WithReceiver`, we will generate a method:
func (t test) Test()
If `WithCall`, we will generate a function call:
func Test(){}()
If `AddBody`, we will generate like a function definition without body:
func Test() {
println("Hello, World!")
}
func LineComment ¶
func NewGroup ¶
func NewGroup() *group
Example ¶
f := NewGroup()
f.AddPackage("main")
f.NewImport().AddPath("fmt")
f.NewFunction("main").AddBody(
String(`fmt.Println("%s")`, "Hello, World!"),
)
fmt.Println(f.String())
Output: package main import "fmt" func main(){ fmt.Println("Hello, World!")}
Types ¶
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
func (*Generator) AppendFile ¶
AppendFile will append the group after the give path.
type IStruct ¶
type IStruct struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.