Trying to send some data using channel. First is a struct, and the other
is for telling me my work is done using signals. Received the two
channels and ran a select for them. In main, i ran two goroutines, but
unfortunately, dont get my result
//use this link to get to the code
https://play.golang.org/p/wi9QlhBGTfr
Should get something like this
//this is the expected result
[widget_0 22:26:15.454569]
[widget_1 22:26:15.454594]
[widget_2 22:26:15.454792]
[widget_3 22:26:15.454792]
https://play.golang.org/p/_oMyr7sLTB7
The issue with waiting was resolved. I implemented the os.Signal, so that when i give it a signal, (ctrl + c) it should end my work. For some reason it ignores that
So your program will never be able to finish without you beeing active and sending it one of the signals specified in your code, eg via CTRL-c in the terminal that runs the program, and the waitgroup gets satisfied by an amount of calls to Done() that is equivalent to the count summed up using calls to Add().
https://play.golang.org/p/e5RyOiaN3nM
Thanks. Resolved the issue. But i noticed i only get even numbers, and ive never been more confused before in my life why its giving me that…Ran 10 goroutines, and added a wg in the cycle everytime it runs…still i dont get all the goroutines running. https://play.golang.org/p/e5RyOiaN3nM
i gets incremented twice per cycle. Once in the loops body and once in the loops “head”. In this kind of loop you shouldn’t mutate the loop variable inside the body unless you know what you are doing.
Because you generate a random integer that is greater than or equal to 0 but less than 5, you use this to create a timer, those needs to be created with a non negative and non-zero duration.
The only “dumb questions” are those that don’t get asked, as my Prof used to say…
But sadly I can’t give any reading recommondations, as I usually learn by using a language and reading API documentation.
Have not used a real book (for programming) since starting with Commodore Basic v3.5 30-ish years ago…
I do learn much better by doing and perhaps talking, than just reading. Sometimes I follow some tutorials from the web, but thats rare.
Though I can for sure recommend exercism.io for learning katas. In mentored mode even real humans will give you feedback, though it might take a while before that happens and you can move on to the next exercises.
Hey, was wondering if you could help me out… https://play.golang.org/p/0U5_YrAYW7o
The comments explain a lot in the code.
Im trying to make a function that returns the type of animal, and pass that function as a parameter. There since to be a problem with type conversion.
The three send functons are sending me the info i need. https://play.golang.org/p/0U5_YrAYW7o
if i didnt explain the question properly, please inform me