package jenimport ()// Comment adds a comment. If the provided string contains a newline, the// comment is formatted in multiline style. If the comment string starts// with "//" or "/*", the automatic formatting is disabled and the string is// rendered directly.func ( string) *Statement {returnnewStatement().Comment()}// Comment adds a comment. If the provided string contains a newline, the// comment is formatted in multiline style. If the comment string starts// with "//" or "/*", the automatic formatting is disabled and the string is// rendered directly.func ( *Group) ( string) *Statement { := Comment() .items = append(.items, )return}// Comment adds a comment. If the provided string contains a newline, the// comment is formatted in multiline style. If the comment string starts// with "//" or "/*", the automatic formatting is disabled and the string is// rendered directly.func ( *Statement) ( string) *Statement { := comment{comment: , } * = append(*, )return}// Commentf adds a comment, using a format string and a list of parameters. If// the provided string contains a newline, the comment is formatted in// multiline style. If the comment string starts with "//" or "/*", the// automatic formatting is disabled and the string is rendered directly.func ( string, ...interface{}) *Statement {returnnewStatement().Commentf(, ...)}// Commentf adds a comment, using a format string and a list of parameters. If// the provided string contains a newline, the comment is formatted in// multiline style. If the comment string starts with "//" or "/*", the// automatic formatting is disabled and the string is rendered directly.func ( *Group) ( string, ...interface{}) *Statement { := Commentf(, ...) .items = append(.items, )return}// Commentf adds a comment, using a format string and a list of parameters. If// the provided string contains a newline, the comment is formatted in// multiline style. If the comment string starts with "//" or "/*", the// automatic formatting is disabled and the string is rendered directly.func ( *Statement) ( string, ...interface{}) *Statement { := comment{comment: fmt.Sprintf(, ...), } * = append(*, )return}type comment struct { comment string}func ( comment) ( *File) bool {returnfalse}func ( comment) ( *File, io.Writer, *Statement) error {ifstrings.HasPrefix(.comment, "//") || strings.HasPrefix(.comment, "/*") {// automatic formatting disabled.if , := .Write([]byte(.comment)); != nil {return }returnnil }ifstrings.Contains(.comment, "\n") {if , := .Write([]byte("/*\n")); != nil {return } } else {if , := .Write([]byte("// ")); != nil {return } }if , := .Write([]byte(.comment)); != nil {return }ifstrings.Contains(.comment, "\n") {if !strings.HasSuffix(.comment, "\n") {if , := .Write([]byte("\n")); != nil {return } }if , := .Write([]byte("*/")); != 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.