bytes, strings: add TrimPrefix and TrimSuffix

Everybody either gets confused and thinks this is
TrimLeft/TrimRight or does this by hand which gets
repetitive looking.

R=rsc, kevlar
CC=golang-dev
https://golang.org/cl/7239044
This commit is contained in:
Brad Fitzpatrick 2013-02-01 08:41:25 -08:00
parent fe14ee52cc
commit e515d80d5d
21 changed files with 117 additions and 54 deletions

View file

@ -778,8 +778,7 @@ func (w *Walker) walkConst(vs *ast.ValueSpec) {
}
}
}
if strings.HasPrefix(litType, constDepPrefix) {
dep := litType[len(constDepPrefix):]
if dep := strings.TrimPrefix(litType, constDepPrefix); dep != litType {
w.constDep[ident.Name] = dep
continue
}