Re: [go-nuts] Channel Feature Suggestion

2019-02-22 Thread Michael Jones
That they do not work is an important issue as has been explained here repeatedly. On Fri, Feb 22, 2019 at 7:59 PM Victor Giordano wrote: > Those idioms should be documented somewhere! > > I would use waiting groups for the rest of the job, i don't know.. have to > think a little more.. you got

[go-nuts] Good metaphor for differentiating Go from other languages?

2019-02-22 Thread Randall O'Reilly
On the topic of “selling” the advantages of Go vs. other languages such as Python and C++, has anyone used the metaphor of other products that strongly emphasize clean, elegant design, such as Apple hardware (I wouldn’t make this case about their software, given the nature of objective-C and

Re: [go-nuts] Channel Feature Suggestion

2019-02-22 Thread Victor Giordano
Those idioms should be documented somewhere! I would use waiting groups for the rest of the job, i don't know.. have to think a little more.. you got the number of background task to wait for, right? El jueves, 21 de febrero de 2019, 10:47:07 (UTC-3), Jan Mercl escribió: > > On Thu, Feb 21,

Re: [go-nuts] How is a for loop preempted in Go?

2019-02-22 Thread Ian Denhardt
In the new example, goroutine 2 should get pre-empted at time.Sleep. goroutine 1 may hog a CPU however. There's an open issue about this, which is being worked on. https://github.com/golang/go/issues/10958 I think it's always been the intent that from the programmer's perspective goroutines

Re: [go-nuts] Need Help - go lambda triggering in post authenticate

2019-02-22 Thread Burak Serdar
On Fri, Feb 22, 2019 at 1:36 AM Merry wrote: > > i have wrote a lambda function in go to trigger the event in cognito, i have > attached the lambda in cognito user ppol when i logged in form UI just before > authenticate i am getting error > json: cannot unmarshal string into Go struct field

Re: [go-nuts] Channel Feature Suggestion

2019-02-22 Thread Robert Engels
It is fairly trivial to create a Spawner structure that wraps the wait group and the counter (max spawns) to do what you want. As others pointed out, waitempty can be racy in the general sense, and prone to incorrect usage. (I did not do a full analysis but I’ll take your word for it that it is

Re: [go-nuts] Channel Feature Suggestion

2019-02-22 Thread Serhat Sevki Dincer
Yes workers could regulate number of spawns with an atomic counter themselves but how would the "master caller" sleep until all those workers are done? It needs to sleep until the counter is zero, Like a WaitGroup. 22 Şub 2019 Cum 15:53 tarihinde Robert Engels şunu yazdı: > But you can replace

Re: [go-nuts] Channel Feature Suggestion

2019-02-22 Thread Robert Engels
But you can replace waitempty() and related with a simple atomic counter variable and avoid channels for this. Far simpler. > On Feb 22, 2019, at 6:38 AM, Serhat Sevki Dincer wrote: > > A little imagination would help us all greatly. Select part would obviously > be in a for loop. Like

Re: [go-nuts] Channel Feature Suggestion

2019-02-22 Thread Serhat Sevki Dincer
A little imagination would help us all greatly. Select part would obviously be in a for loop. Like this: func worker() { // do work, prepare whatever for some_condition{ // do stuff Select { ch <- true: go worker() // try to handover some jobs default: // max goroutine limit

Re: [go-nuts] Channel Feature Suggestion

2019-02-22 Thread Robert Engels
I’m pretty sure this code is incorrect and there will only be a single routine doing any “real work”, although the comment //do remaining jobs is unclear because there is no code. > On Feb 22, 2019, at 12:42 AM, Serhat Şevki Dinçer wrote: > > Another use case is wait groups with Max number

Re: [go-nuts] The Seven Finest Go Books (to popularize and 'socialize' Go).

2019-02-22 Thread Akram Ahmad
- Excellent! I will add your book to my list of Go books—the list keeps burgeoning, a good thing of course—to check out and tell my blog-readers (and others!) to check out in turn :) - I thank you, Nathan. On Friday, February 22, 2019 at 3:29:29 AM

Re: [go-nuts] The Seven Finest Go Books (to popularize and 'socialize' Go).

2019-02-22 Thread roger peppe
You might want to take a look at Manning's "Get Programming With Go" too; it's aimed mostly at more inexperienced programmers. https://www.amazon.com/Get-Programming-Go-Nathan-Youngman/dp/1617293091 (disclosure: I'm one of the authors :]) On Thu, 21 Feb 2019 at 23:02, Akram Ahmad wrote: > >

[go-nuts] Re: sharing types between interface and implementation

2019-02-22 Thread Manlio Perillo
The problem is that these types must be used by packages importing my package. I'm in doubt between declaring identical (but not compatible) types like in the sql package, or using type alias to have true identical types. Thanks Manlio Perillo On Friday, February 22, 2019 at 3:26:03 AM UTC+1,

[go-nuts] cleaner - a simple tool to make large source files a bit less messy

2019-02-22 Thread Louki Sumirniy
I may be one of the most obsessive about the subject of source code layouts, partly because of the impact that especially large and disorganised source files (at least to the extent of the individual files, but packages can get really nasty too). It took me some time to navigate to find the

[go-nuts] Need Help - go lambda triggering in post authenticate

2019-02-22 Thread Merry
i have wrote a lambda function in go to trigger the event in cognito, i have attached the lambda in cognito user ppol when i logged in form UI just before authenticate i am getting error json: cannot unmarshal string into Go struct field CognitoEvent.version of type int: UnmarshalTypeError null

Re: [go-nuts] How is a for loop preempted in Go?

2019-02-22 Thread Jingguo Yao
Yes, my fault. Thanks for pointing it out. What happens if I remove the fmt.Printf function calls to have the following code: package main import ( "fmt" "runtime" "time" ) func main() { count := runtime.GOMAXPROCS(1) fmt.Printf("GOMAXPROCS: %d\n", count) // goroutine 1 go func() { for { }

Re: [go-nuts] How is a for loop preempted in Go?

2019-02-22 Thread Jan Mercl
On Fri, Feb 22, 2019 at 9:17 AM Jingguo Yao wrote: > Without preemption, the M will run goroutine 1 or goroutine 2 continuously. Not correct, there's also cooperative scheduling/yielding. > The messages sent to the terminal should be all 1s or all 2s. Nothing in the language specs mandates

Re: [go-nuts] How is a for loop preempted in Go?

2019-02-22 Thread Ian Denhardt
Quoting Jingguo Yao (2019-02-22 03:17:33) >Since both goroutines do not make any function calls fmt.Printf is a function. -- 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

[go-nuts] How is a for loop preempted in Go?

2019-02-22 Thread Jingguo Yao
Consider the following code which launches two goroutines. Each goroutine uses a for loop to print messages. package main import ( "fmt" "runtime" "time" ) func main() { count := runtime.GOMAXPROCS(1) fmt.Printf("GOMAXPROCS: %d\n", count) // goroutine 1 go func() { for