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
+8.9k Golang : What is the default port number for connecting to MySQL/MariaDB database ?
+5k Golang : micron to centimeter example
+16.6k Golang : Generate QR codes for Google Authenticator App and fix "Cannot interpret QR code" error
+8.5k PHP : How to parse ElasticSearch JSON ?
+7.1k Golang : Validate credit card example
+14.6k Golang : GUI with Qt and OpenCV to capture image from camera
+7.9k Javascript : How to check a browser's Do Not Track status?
+14.7k Golang : Reset buffer example
+6.1k Golang : Scan forex opportunities by Bollinger bands
+4.7k Golang : How to pass data between controllers with JSON Web Token
+8.1k Golang : Variadic function arguments sanity check example