mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-06-22 01:41:55 +08:00
fix(stringx): return empty string from FirstN when n is negative (#5620)
This commit is contained in:
@@ -34,6 +34,10 @@ func Filter(s string, remove func(r rune) bool) string {
|
||||
|
||||
// FirstN returns first n runes from s.
|
||||
func FirstN(s string, n int, ellipsis ...string) string {
|
||||
if n < 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
var i int
|
||||
|
||||
for j := range s {
|
||||
|
||||
Reference in New Issue
Block a user