Basic HTTP client.

R=rsc
APPROVED=rsc
DELTA=392  (386 added, 2 deleted, 4 changed)
OCL=29963
CL=30107
This commit is contained in:
Steve Newman 2009-06-09 10:58:58 -07:00
parent c4aa021733
commit f315fb3d56
6 changed files with 392 additions and 6 deletions

View file

@ -53,6 +53,21 @@ func Index(s, sep string) int {
return -1
}
// Index returns the index of the last instance of sep in s, or -1 if sep is not present in s.
func LastIndex(s, sep string) int {
n := len(sep);
if n == 0 {
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) {
return i
}
}
return -1
}
// Split returns the array representing the substrings of s separated by string sep. Adjacent
// occurrences of sep produce empty substrings. If sep is empty, it is the same as Explode.
func Split(s, sep string) []string {