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
+17.5k Golang : Clone with pointer and modify value
+4.6k JavaScript : Rounding number to decimal formats to display currency
+28.6k Golang : Read, Write(Create) and Delete Cookie example
+6k Golang : How to verify input is rune?
+20.2k Golang : How to get struct tag and use field name to retrieve data?
+14.6k Golang : Convert(cast) int to float example
+22k Fix "Failed to start php5-fpm.service: Unit php5-fpm.service is masked."
+17.9k Golang : Simple client server example
+12.2k Golang : Simple client-server HMAC authentication without SSL example
+4.8k Which content-type(MIME type) to use for JSON data
+17.7k How to enable MariaDB/MySQL logs ?