MCPcopy Create free account
hub / github.com/dolthub/doltgresql / SectionMarker

Function SectionMarker

testing/generation/utils/section_marker.go:27–37  ·  view source on GitHub ↗

SectionMarker returns a marker that may be used to denote sections. For example, SectionMarker("abc", '-', 21) would return: -------- abc --------

(centeredText string, fillerCharacter rune, totalLength int)

Source from the content-addressed store, hash-verified

25//
26// -------- abc --------
27func SectionMarker(centeredText string, fillerCharacter rune, totalLength int) string {
28 fillerStr := string(fillerCharacter)
29 remainingLength := totalLength - (len(centeredText) + 2)
30 if remainingLength <= 0 {
31 return fmt.Sprintf(" %s ", centeredText)
32 }
33 left := remainingLength / 2
34 right := remainingLength - left // Integer division doesn't do fractions, so this will handle odd counts
35 return fmt.Sprintf("%s %s %s",
36 strings.Repeat(fillerStr, left), centeredText, strings.Repeat(fillerStr, right))
37}
38
39// PrintSectionMarker is a convenience function that prints the result of SectionMarker with a newline appended.
40func PrintSectionMarker(centeredText string, fillerCharacter rune, totalLength int) {

Callers 2

PrintSectionMarkerFunction · 0.85

Calls 1

RepeatMethod · 0.80

Tested by

no test coverage detected