Re: [go-nuts] all goroutines are asleep - deadlock!

2017-08-06 Thread Konstantin Khomoutov
On Fri, Aug 04, 2017 at 08:11:45AM -0700, prankpla...@gmail.com wrote: [...] > func fact_worker(fact_resp_chan chan string, x int) { > defer wg.Done() > response := factorial(x) > fact_resp_chan <- fmt.Sprintf("Factorial of %d is : %d", x, response) > } [...] Please also consider naming your ide

[go-nuts] Re: Goroutines chan to get data at specific time

2017-08-06 Thread Timothy Raymond
I'm not entirely sure, but my intuition says that using `time.After` like that with pending sends from another goroutine will cause that goroutine to leak. A better solution may be to use the `WithTimeout` functionality of the `context` package and then periodically check the `Done()` channel to

Re: [go-nuts] Re: [Go2] Reflect

2017-08-06 Thread Gert
On Monday, August 7, 2017 at 12:41:18 AM UTC+2, kortschak wrote: > > The reflect package is not mentioned in the spec (except once to > discuss struct tags), adding a built-in would require its definition > there, and complicate the language. Making it easier to use would also > have the disad

Re: [go-nuts] [CGO] how to pass a 2d slice to C?

2017-08-06 Thread jianzhangbjz
Thanks your reply, I also used this way, but it still not work. code as the following. gonameunits := []string{"gpu0", "gpu1", "gpu2", "gpu3"} nameunits := make([]*C.char, len(gonameunits)) for i, _ := range gonameunits { nameunits[i] = C.CString(gonameunits[i]) defer C.free(u

Re: [go-nuts] Re: [Go2] Reflect

2017-08-06 Thread Dan Kortschak
>From the Laws of Reflection[1]: > It's a powerful tool that should be used with care and avoided unless > strictly necessary.  The reflect package is not mentioned in the spec (except once to discuss struct tags), adding a built-in would require its definition there, and complicate the language.

[go-nuts] Re: [Go2] Reflect

2017-08-06 Thread Gert
Yes but its the way it's done that i think could be made more straightforward, why not merge ValueOf and TypeOf in a build in intermediate reflect type as in for example int(4) but then reflect(4) On Sunday, August 6, 2017 at 5:57:40 PM UTC+2, Rich wrote: > > I don't understand... doesn't Reflec

[go-nuts] Re: [Go2] Reflect

2017-08-06 Thread Rich
I don't understand... doesn't Reflect already do this? https://play.golang.org/p/CIm7aISztv On Saturday, August 5, 2017 at 12:58:52 PM UTC-4, Gert wrote: > > package main > > import ( > "fmt" > "reflect" > ) > > func main() { > x := 4 > v1 := reflect.ValueOf(x) > fmt.Println("type:", v1.Type()) >

[go-nuts] Re: Goroutines chan to get data at specific time

2017-08-06 Thread desaiabhijit
yes this is what I want.. Need to access web service multiple times to get the entire data unless return status is not "completed" But same time I need timeout Thanks for the help Thanks Abhi On Sunday, August 6, 2017 at 7:48:05 PM UTC+5:30, snmed wrote: > > I still no get the idea behind yo

[go-nuts] Re: Goroutines chan to get data at specific time

2017-08-06 Thread snmed
I still no get the idea behind your requirement, in your example you calling the web service 6 times in sequential manner and then write it to the channel. But again you can only write once to a channel with a capacity of one, as long as you not read from the same channel and you still read it i

[go-nuts] Re: Tell "dep" to ignore a dependency?

2017-08-06 Thread Miki Tebeka
Wasn't aware this is possible, will do - thanks. On Sunday, August 6, 2017 at 4:53:13 PM UTC+3, Paul Tötterman wrote: > > Thanks. But if I'll use constraint I'll need to rewrite all the import >> paths in my code (and maybe in the vendor directory as well) >> > > Maybe I've misunderstood somethin

[go-nuts] Re: Goroutines chan to get data at specific time

2017-08-06 Thread desaiabhijit
hi Bjoern >>> Why would you expect this? "result 1" is the fist value that was sent to the channel. Channels are sort of FIFO. Yeah I know.. but what is the workaround to get latest c1 value which is retrieve just before timeout Do I need to use "for ( loop )" around Select till timeout to inv

[go-nuts] Re: Tell "dep" to ignore a dependency?

2017-08-06 Thread paul . totterman
> > Thanks. But if I'll use constraint I'll need to rewrite all the import > paths in my code (and maybe in the vendor directory as well) > Maybe I've misunderstood something, but I was expecting you wouldn't have to: [[constraint]] name = "github.com/original/library" source = "github.com/you

[go-nuts] Re: Tell "dep" to ignore a dependency?

2017-08-06 Thread Miki Tebeka
Thanks. But if I'll use constraint I'll need to rewrite all the import paths in my code (and maybe in the vendor directory as well) On Sunday, August 6, 2017 at 4:31:25 PM UTC+3, Paul Tötterman wrote: > > Hi, > > I plan to use "dep" and also to place "vendor" in the git repository. >> However I

[go-nuts] Re: Tell "dep" to ignore a dependency?

2017-08-06 Thread paul . totterman
Hi, I plan to use "dep" and also to place "vendor" in the git repository. > However I have one dependency in vendor which is locally patched. The > problem for me is that "dep ensure" overwrites my patch every time. Is > there a way to tell "dep" to ignore this specific package? (There are > o

[go-nuts] Re: Goroutines chan to get data at specific time

2017-08-06 Thread bjoern.pirnay via golang-nuts
Am Sonntag, 6. August 2017 09:53:36 UTC+2 schrieb Abhijit Desai: > > Can you please help with below code to get output at specific cutoff time > and exit > > Thanks in advance > > Abhi > > > > package main > > import "time" > import "fmt" > > func main() { > > c1 := make(chan string) >

Re: [go-nuts] Re: How to optimize as with -O2 from Gcc? (50x speedup)

2017-08-06 Thread Dorival Pedroso
Fixed. Cheers. On Sunday, August 6, 2017 at 12:23:57 PM UTC+10, Michael Jones wrote: > > Great. Hope it helps. I had a typo in power 0 (which is never called. > Change the return to 1.0. > > On Sat, Aug 5, 2017 at 6:50 PM > wrote: > >> Thanks, Michael. >> >> I've created a tiny project with those

[go-nuts] Re: Concurrency Testimonial

2017-08-06 Thread Dorival Pedroso
Great news. Thanks for sharing On Sunday, August 6, 2017 at 1:37:11 AM UTC+10, Mandolyte wrote: > > This past week I wrote an "audit" program for management to see how a long > running data migration effort was going (it will take several months to > complete). I was little discouraged when I fo

[go-nuts] Re: Goroutines chan to get data at specific time

2017-08-06 Thread desaiabhijit
Requirement is to collect the data with in cuttoff time say 3 sec by invoking web service multiple times and return only latest invoked data c1 <- "result 1" // In real scenario this taking almost 1 seconds as in real scenario it's taking Part chunk of data from Web Service Something like... Ex

[go-nuts] Re: Generics are overrated.

2017-08-06 Thread Lucio
Got it. In the same document: "Halfway the functional design of the X1, I guess early 1957, Bram and Carel confronted me with the idea of the interrupt, and I remember that I panicked, being used to machines with reproducible behaviour. How was I going to identify a bug if I had introduced one?

[go-nuts] Goroutines chan to get data at specific time

2017-08-06 Thread snmed
Hi What are you trying to solve? Your channel has a capacity of 1, the first write to c1 is successful but the second write to c1 is blocked until it has been read in the select statement. And therefore you print the first value written to c1. I recommend you to read this https://golang.org/d

[go-nuts] Re: Generics are overrated.

2017-08-06 Thread Lucio
Thank you, Peter. Maybe someone else can corroborate my impression that Dijkstra did not immediately accept the idea of interrupts and felt it would make programming too difficult? Lucio. On Saturday, 5 August 2017 19:44:26 UTC+2, peterGo wrote: > > Lucio, > > "It took Dijkstra quite some effo

[go-nuts] Tell "dep" to ignore a dependency?

2017-08-06 Thread Miki Tebeka
Hi, I plan to use "dep" and also to place "vendor" in the git repository. However I have one dependency in vendor which is locally patched. The problem for me is that "dep ensure" overwrites my patch every time. Is there a way to tell "dep" to ignore this specific package? (There are overrides

[go-nuts] Goroutines chan to get data at specific time

2017-08-06 Thread desaiabhijit
Can you please help with below code to get output at specific cutoff time and exit Thanks in advance Abhi package main import "time" import "fmt" func main() { c1 := make(chan string) go func() { //Sending data after certain time c1 <- "result 1" time.Sleep