1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00
cowyo/vendor/github.com/shurcooL/go/trim/trim.go

19 lines
406 B
Go
Raw Normal View History

2017-10-03 21:43:55 +03:00
// Package trim contains helpers for trimming strings.
package trim
// LastNewline trims the last newline character from s, if any.
func LastNewline(s string) string {
if len(s) < 1 || s[len(s)-1] != '\n' {
return s
}
return s[:len(s)-1]
}
// FirstSpace trims the first space character from s, if any.
func FirstSpace(s string) string {
if len(s) < 1 || s[0] != ' ' {
return s
}
return s[1:]
}