348032 (2) [Avatar] Offline
#1
Having a hard time understanding the following declaration on the Runner code:

19 // complete channel reports that processing is done.
20 complete chan error
21
22 // timeout reports that time has run out.
23 timeout <-chan time.Time”

is error a keyword? What about the second statement? Is it saying it is buffered channel?

Thanks in advance.
Bill Kennedy (68) [Avatar] Offline
#2
These are declarations in the struct type. They are not initialized that this point, just declaring the Runner type.

complete chan error

This is declaring a field named complete that is of type chan error.
error is the error interface type

timeout <-chan time.Time

This is declaring a field named timeout that is of type chan time.Time.
The arrow is specifying that the channel is read only.
348032 (2) [Avatar] Offline
#3
Thanks got it. I don't think I saw that declaration in previous examples, previous examples used declare and assign using "make". I don't think I saw "<-" as readonly on previous examples either. I apologize ahead of time if I missed.

Thanks again,
Alex
pires (4) [Avatar] Offline
#4
I had the exact same doubt while crossing this piece of code, but had to find my way in #go-nuts @ irc.freenode.net. Btw, perhaps a reference to that channel would be a plus?
388432 (1) [Avatar] Offline
#5
Thank you. This helped me with my site binaereoptionen.org
Bill Kennedy (68) [Avatar] Offline
#6
AWESOME !!!