c088cb2642
* vendor bencode library github.com/zeebo/bencode * add metainfo parsing library from XD * fix up upload handler so to be less cluttered
17 lignes
343 o
Go
17 lignes
343 o
Go
package util
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
// return true if r is a whitespace rune
|
|
func IsWhitespace(r rune) bool {
|
|
return r == '\n' || r == '\t' || r == '\r' || r == ' '
|
|
}
|
|
|
|
// trim whitespaces from a string
|
|
func TrimWhitespaces(s string) string {
|
|
s = strings.TrimLeftFunc(s, IsWhitespace)
|
|
s = strings.TrimRightFunc(s, IsWhitespace)
|
|
return s
|
|
}
|