func WrapLine(line string, length int) (lines []string) {
	// split it into strings
	fields := strings.Fields(line)

	// wrapping at length 0 makes no sense
	if length <= 0 {
		return []string{strings.Join(fields, " ")}
	}

	// while we have a field left
	for len(fields) > 0 {
		newLine := ""

		for len(fields) > 0 {
			// the next element
			next := fields[0]

			// the space seperator we have to add
			space := " "
			if newLine == "" {
				space = ""
			}

			// if we have enough space
			// or we are at the first word to add to the line
			if (len(newLine)+1+len(next) < length) || newLine == "" {
				newLine += space + next
				fields = fields[1:]

				// else we break and skip to the next line
			} else {
				break
			}
		}

		// add the line to the buffer
		lines = append(lines, newLine)
	}

	return
}
// WrapLine wraps a single line at length, not preserving any whitespace
WrapLine wraps a single line at length, not preserving any whitespace
// WrapLine wraps a single line at length not preserving any whitespace
func WrapLine(line string, length int) (lines []string) {
	fields := strings.Fields(line)
	if length <= 0 {
		return []string{strings.Join(fields, " ")}
	}
	for len(fields) > 0 {
		newLine := ""
		for len(fields) > 0 {
			next := fields[0]
			space := " "
			if newLine == "" {
				space = ""
			}
			if (len(newLine)+1+len(next) < length) || newLine == "" {
				newLine += space + next
				fields = fields[1:]
			} else {
				break
			}
		}
		lines = append(lines, newLine)
	}
	return
}
func WrapLine ( line string , length int ) ( lines [ ] string ) { fields := strings . Fields ( line ) if length <= 0 { return [ ] string { strings . Join ( fields , " " ) } } for len ( fields ) > 0 { newLine := " " for len ( fields ) > 0 { next := fields [ 0 ] space := " " if newLine == " " { space = " " } if ( len ( newLine ) + 1 + len ( next ) < length ) || newLine == " " { newLine += space + next fields = fields [ 1 : ] } else { break } } lines = append ( lines , newLine ) } return }
WrapLine wraps a single line at length, not preserving any whitespace
WrapLine wraps a single line at length not preserving any whitespace
// split it into strings // wrapping at length 0 makes no sense // while we have a field left // the next element // the space seperator we have to add // if we have enough space // or we are at the first word to add to the line // else we break and skip to the next line // add the line to the buffer