I've been reading the [golang-book]: http://www.golang-book.com and completing the excercises as I go along. In Chapter 6, there is an exercise that must find the smallest element in an unsorted list[x].
I have the following code but somehow I don't know why the method length (len) gives me an error on line 14: x.len undefined (type []int has no field or method len)
package main
import "fmt"
func main() {
x := []int{
48, 96, 86, 68,
57, 82, 63, 70,
37, 34, 83, 27,
19, 97, 9, 17,
}
small := x[0]
for i := 1; i < x.len(); i++ {
if x[i] < small {
fmt.Println(x[i])
}
}
}
The logic I used was Googled so perhaps there is no len method on arrays? Any help is greatly appreciated.