Thanks a lot, Ian, it works now.

On Thursday, June 11, 2020 at 2:17:23 PM UTC+8, Ian Lance Taylor wrote:
>
> On Wed, Jun 10, 2020 at 11:05 PM xiang...@gmail.com <javascript:> 
> <xiang...@gmail.com <javascript:>> wrote: 
> > 
> > Wondering if the 'expression' part of an if-statement should be in one 
> line only, given the following case, 'go tool compile' will report a syntax 
> error 
> > 
> > Enter code here... 
> > package p 
> > 
> > func cf1() int { 
> >         return 0 
> > } 
> > 
> > func cf2() int { 
> >         return 10 
> > } 
> > 
> > func f() { 
> >         if cf2() - 1 
> >                 < cf1() { 
> >                 println("tested") 
> >         } 
> > } 
> > 
> > 
> > ss.go:13:3: syntax error: unexpected <, expecting expression 
> > 
> > Guess there might be syntax specification rules but I failed to find 
> out. 
>
> It's because of automatic semicolon insertion.  You need to put the 
> "<" at the end of the "if" line, not at the start of the next line. 
> See https://golang.org/ref/spec#Semicolons . 
>
> Ian 
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/b06a5576-6d9b-4066-9017-b6aeb61a665do%40googlegroups.com.

Reply via email to