summaryrefslogtreecommitdiff
path: root/src/pkg/strings/strings.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/strings/strings.go')
-rw-r--r--src/pkg/strings/strings.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/pkg/strings/strings.go b/src/pkg/strings/strings.go
index 5e1b5b35c..055d7d1e9 100644
--- a/src/pkg/strings/strings.go
+++ b/src/pkg/strings/strings.go
@@ -41,9 +41,9 @@ func Count(s, sep string) int {
c := sep[0];
n := 0;
for i := 0; i+len(sep) <= len(s); i++ {
- if s[i] == c && (len(sep) == 1 || s[i : i+len(sep)] == sep) {
+ if s[i] == c && (len(sep) == 1 || s[i:i+len(sep)] == sep) {
n++;
- i += len(sep)-1;
+ i += len(sep) - 1;
}
}
return n;
@@ -57,7 +57,7 @@ func Index(s, sep string) int {
}
c := sep[0];
for i := 0; i+n <= len(s); i++ {
- if s[i] == c && (n == 1 || s[i : i+n] == sep) {
+ if s[i] == c && (n == 1 || s[i:i+n] == sep) {
return i
}
}
@@ -71,8 +71,8 @@ func LastIndex(s, sep string) int {
return len(s)
}
c := sep[0];
- for i := len(s)-n; i >= 0; i-- {
- if s[i] == c && (n == 1 || s[i : i+n] == sep) {
+ for i := len(s) - n; i >= 0; i-- {
+ if s[i] == c && (n == 1 || s[i:i+n] == sep) {
return i
}
}
@@ -93,11 +93,11 @@ func genSplit(s, sep string, sepSave, n int) []string {
a := make([]string, n);
na := 0;
for i := 0; i+len(sep) <= len(s) && na+1 < n; i++ {
- if s[i] == c && (len(sep) == 1 || s[i : i+len(sep)] == sep) {
+ if s[i] == c && (len(sep) == 1 || s[i:i+len(sep)] == sep) {
a[na] = s[start : i+sepSave];
na++;
- start = i+len(sep);
- i += len(sep)-1;
+ start = i + len(sep);
+ i += len(sep) - 1;
}
}
a[na] = s[start:len(s)];
@@ -125,7 +125,7 @@ func Join(a []string, sep string) string {
if len(a) == 1 {
return a[0]
}
- n := len(sep)*(len(a)-1);
+ n := len(sep) * (len(a) - 1);
for i := 0; i < len(a); i++ {
n += len(a[i])
}
@@ -156,7 +156,7 @@ func HasPrefix(s, prefix string) bool {
// HasSuffix tests whether the string s ends with suffix.
func HasSuffix(s, suffix string) bool {
- return len(s) >= len(suffix) && s[len(s)-len(suffix) : len(s)] == suffix
+ return len(s) >= len(suffix) && s[len(s)-len(suffix):len(s)] == suffix
}
// Map returns a copy of the string s with all its characters modified