package jenimport ()// Statement represents a simple list of code items. When rendered the items// are separated by spaces.typeStatement []Codefunc newStatement() *Statement {return &Statement{}}// Clone makes a copy of the Statement, so further tokens can be appended// without affecting the original.func ( *Statement) () *Statement {return &Statement{}}func ( *Statement) ( Code) Code { := -1for , := range * {if == { = break } }if > 0 {return (*)[-1] }returnnil}func ( *Statement) ( *File) bool {if == nil {returntrue }for , := range * {if !.isNull() {returnfalse } }returntrue}func ( *Statement) ( *File, io.Writer, *Statement) error { := truefor , := range * {if == nil || .isNull() {// Null() token produces no output but also // no separator. Empty() token products no // output but adds a separator.continue }if ! {if , := .Write([]byte(" ")); != nil {return } }if := .render(, , ); != nil {return } = false }returnnil}// Render renders the Statement to the provided writer.func ( *Statement) ( io.Writer) error {return .RenderWithFile(, NewFile(""))}// GoString renders the Statement for testing. Any error will cause a panic.func ( *Statement) () string { := bytes.Buffer{}if := .Render(&); != nil {panic() }return .String()}// RenderWithFile renders the Statement to the provided writer, using imports from the provided file.func ( *Statement) ( io.Writer, *File) error { := &bytes.Buffer{}if := .render(, , nil); != nil {return } , := format.Source(.Bytes())if != nil {returnfmt.Errorf("Error %s while formatting source:\n%s", , .String()) }if , := .Write(); != nil {return }returnnil}
The pages are generated with Goldsv0.8.4. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.