Every line of 'golang trim whitespace' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.
49 func Trim(str, chars string) string { 50 return LeftTrim(RightTrim(str, chars), chars) 51 }
1479 func normalizeWhitespace(x string) string { 1480 x = strings.Join(strings.Fields(x), " ") 1481 x = strings.Replace(x, "( ", "(", -1) 1482 x = strings.Replace(x, " )", ")", -1) 1483 x = strings.Replace(x, ")->", ") ->", -1) 1484 return x 1485 }
94 func (t *Segment) TrimLeftSpaceWidth(width int, buffer []byte) Segment { 95 padding := t.Padding 96 for ; width > 0; width-- { 97 if padding == 0 { 98 break 99 } 100 padding-- 101 } 102 if width == 0 { 103 return NewSegmentPadding(t.Start, t.Stop, padding) 104 } 105 text := buffer[t.Start:t.Stop] 106 start := t.Start 107 for _, c := range text { 108 if start >= t.Stop-1 || width <= 0 { 109 break 110 } 111 if c == ' ' { 112 width-- 113 } else if c == '\t' { 114 width -= 4 115 } else { 116 break 117 } 118 start++ 119 } 120 if width < 0 { 121 padding = width * -1 122 } 123 return NewSegmentPadding(start, t.Stop, padding) 124 }
31 func (e *Echo) Trim(val string) string { 32 return strings.TrimSpace(e.Variables().Eval(val)) 33 }
261 func trim(x *decimal) { 262 i := len(x.mant) 263 for i > 0 && x.mant[i-1] == '0' { 264 i-- 265 } 266 x.mant = x.mant[:i] 267 if i == 0 { 268 x.exp = 0 269 } 270 }
43 func (q Quoter) Trim(s string) string { 44 if len(s) < 2 { 45 return s 46 } 47 48 var buf strings.Builder 49 for i := 0; i < len(s); i++ { 50 switch { 51 case i == 0 && s[i] == q.Prefix: 52 case i == len(s)-1 && s[i] == q.Suffix: 53 case s[i] == q.Suffix && s[i+1] == '.': 54 case s[i] == q.Prefix && s[i-1] == '.': 55 default: 56 buf.WriteByte(s[i]) 57 } 58 } 59 return buf.String() 60 }
420 func cleanWithoutTrim(s string) string { 421 var b []byte 422 var p byte 423 for i := 0; i < len(s); i++ { 424 q := s[i] 425 if q == '\n' || q == '\r' || q == '\t' { 426 q = ' ' 427 } 428 if q != ' ' || p != ' ' { 429 b = append(b, q) 430 p = q 431 } 432 } 433 return string(b) 434 }
60 func trim(s string) string { 61 if len(s) < 256 { 62 return s 63 } 64 return s[:255] 65 }
639 func trimLeft(buf []byte) []byte { 640 for i, b := range buf { 641 if b != ' ' && b != '\t' { 642 return buf[i:] 643 } 644 } 645 return nil 646 }
509 func TrimLeftFunc(s string, f func(rune) bool) string { 510 i := indexFunc(s, f, false) 511 if i == -1 { 512 return "" 513 } 514 return s[i:] 515 }