./main.go:10: non-declaration statement outside function body

781 views
Skip to first unread message

Roelof Wobben

unread,
Jan 23, 2015, 12:03:57 PM1/23/15
to golan...@googlegroups.com
Hello,

I try to solve this problem :

  • Write a program that finds the smallest number in this list:

    x := []int{
        48,96,86,68,
        57,82,63,70,
        37,34,83,27,
        19,97, 9,17,
    }

So I did this :

  • Write a program that finds the smallest number in this list:

    package main

  • import "fmt"

  • x := []int{
        48,96,86,68,
        57,82,63,70,
        37,34,83,27,
        19,97, 9,17,
    }

  • func main() {
      answer := 0 ;
      for i:= 1; i <= len(x) ; i++ {
         if x[i] > answer {
           answer = x[i]
         }
        fmt.Println(answer)
      }
    }

but now I see this error message :

# command-line-arguments                                                                                                                                                               
./main.go:10: non-declaration statement outside function body

Roelof


Benjamin Ruston

unread,
Jan 23, 2015, 12:12:45 PM1/23/15
to Roelof Wobben, golan...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages