Standard library / go/doc/comment

go/doc/comment.Code

Represents preformatted code content. Expected stdout: 'x := 1\n'.

Formal Syntax & Structure

go syntaxgo
type Code struct {  Text string}

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/doc/comment"  "strings")
func main() {  p := comment.Parser{}  d := p.Parse("Example:\n\n    x := 1\n")  x := d.Content[1].(*comment.Code)  fmt.Println(strings.TrimSpace(x.Text))}
Go Reference