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
2017-10-03 14:43:55 -04:00

19 lines
406 B
Go

// 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:]
}