views:

174

answers:

1

In bytes_test.go I see:

 a := Split([]byte(tt.s), []byte(tt.sep), tt.n)

where tt.s and tt.sep are strings. But when I try to do

 a := bytes.Split([]byte("test"), []byte("e"), 0)

I get:

 cannot convert "test" (type ideal string) to type []uint8 in conversion
 cannot convert "e" (type ideal string) to type []uint8 in conversion
+1  A: 

The following is valid code using the latest release -- release.2010-03-04 -- which includes, amongst other things, this change: "There is one language change: the ability to convert a string to []byte or []int. This deprecates the strings.Bytes and strings.Runes functions."

package main

import ("bytes"; "fmt")

func main() {
    a := bytes.Split([]byte("test"), []byte("e"), 0)
    fmt.Println(a)
}

Update to a current release of Go: Installing Go : Keeping up with releases.

peterSO
Thanks! It seems I just got confused with my PATH and was using older version (while having new).
idavydov