You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: trivia.go
    path of file: ./repos/terraform/internal/command/format
    
    the code of the file until where you have to start completion: // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BU
    
func WordWrap(str string, width int) string {
	if width <= 1 {
		// Silly edge case. We'll just return the original string to avoid
		// panicking or doing other weird stuff.
		return str
	}

	var buf strings.Builder
	lines := strings.Split(str, "\n")
	for i, line := range lines {
		if !strings.HasPrefix(line, " ") {
			line = wordwrap.WrapString(line, uint(width-1))
		}
		if i > 0 {
			buf.WriteByte('\n') // reintroduce the newlines we skipped in Scan
		}
		buf.WriteString(line)
	}
	return buf.String()
}