Golang go/doc.ToText() function example
package go/doc
ToText prepares comment text for presentation in textual output. It wraps paragraphs of text to width or fewer Unicode code points and then prefixes each line with the indent. In preformatted sections (such as program text), it prefixes each non-blank line with preIndent.
Golang go/doc.ToText() function usage example
package main
import (
"fmt"
"go/doc"
"bytes"
)
func main() {
var buf bytes.Buffer
comment := "// this line is a comment line"
doc.ToText(&buf, comment, "**", "####", 30)
fmt.Println(buf.String())
}
Output :
**// this line is a comment line
Reference :
Advertisement
Something interesting
Tutorials
+9.4k Golang : Terminate-stay-resident or daemonize your program?
+6.3k Unix/Linux : Use netstat to find out IP addresses served by your website server
+19.1k Golang : Display list of time zones with GMT
+6.5k Golang : Convert an executable file into []byte example
+10.5k Golang : Create matrix with Gonum Matrix package example
+29.9k Golang : Get and Set User-Agent examples
+32.7k Golang : Regular Expression for alphanumeric and underscore
+10.1k Golang : Identifying Golang HTTP client request
+17.4k Golang : Multi threading or run two processes or more example
+6.7k Golang : Skip or discard items of non-interest when iterating example
+8k Findstr command the Grep equivalent for Windows
+11.3k Golang : Characters limiter example