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
+6.7k Golang : Check if password length meet the requirement
+11k How to test Facebook App on localhost ?
+16.9k Golang : Read integer from file into array
+16.6k Golang : Merge video(OpenCV) and audio(PortAudio) into a mp4 file
+9.6k Golang : Validate IPv6 example
+35.5k Golang : Smarter Error Handling with strings.Contains()
+15.9k Golang : Get current time from the Internet time server(ntp) example
+8.8k Yum Error: no such table: packages
+22.1k Golang : Join arrays or slices example
+21.1k Golang : Sort and reverse sort a slice of strings
+14.3k Golang : Simple word wrap or line breaking example
+9.9k Golang : Ordinal and Ordinalize a given number to the English ordinal numeral