Re: [go-nuts] Re: Algorithm Club

2017-04-06 Thread Will Faught
On Sat, Apr 1, 2017 at 12:11 AM, Egon Elbre wrote: > On Sat, Apr 1, 2017 at 1:42 AM, Will Faught wrote: > >> >>> For example []GenericElement could be boxed as: >>> >>> struct{ itab ptr; ... data []struct{elem ptr} } >>> or >>> []struct{itab, elem ptr} >>> >>> >> Can you explain in more detail w

[go-nuts] Redis - Golang >> dial unix /var/run/redis/redis.sock: connect: resource temporarily unavailable

2017-04-06 Thread desaiabhijit
Please help Invoking Redis using "gopkg.in/redis.v4" library Application works fine for single request but it returns "dial unix /var/run/redis/redis.sock: connect: resource temporarily unavailable" when try to use wrk under load -t50 -c50 -d10s trying to get the key using value, exp = red

Re: [go-nuts] Recommended design pattern for real-time monitoring and control of an observatory

2017-04-06 Thread Sebastien Binet
James, On Thu, Apr 6, 2017 at 2:22 AM, James McHugh wrote: > I'm writing some software to monitor and control my observatory. It will > have many many inputs (clouds, rain, temp, time, roof position, telescope > status, focuser status, camera status, filter status etc etc ) and will > control th

[go-nuts] Re: Stop HTTP Server with Context cancel

2017-04-06 Thread Pierre Durand
I did it for a good reason: If the context is canceled `srv.Shutdown` is called. Then, `<-errCh` is not called anymore. This code ensures that there is not leaking goroutine. Le mercredi 5 avril 2017 07:13:19 UTC+2, Johnny Luo a écrit : > > func listenAndServe(ctx context.Context, srv *http.Server

[go-nuts] Re: Stop HTTP Server with Context cancel

2017-04-06 Thread Kemal Hadimli
Isn't the select processing order random? IIRC the only guarantee is "default" case is handled as a low priority. So, something like this maybe? select { case errCh <- err: default: select { case <-ctx.Done(): } } Again, take this with a grain of salt. I didn't check the spec or code, just off

[go-nuts] Re: Stop HTTP Server with Context cancel

2017-04-06 Thread Pierre Durand
Yes you're right, the processing order is pseudo random. But my code also handle another edge case: If `srv.ListenAndServe()` returns an error BEFORE we reach the code `case err := <-errCh:`, with `default` the error is ignored. My code ensure that: - there is no leaking goroutine - returned err

Re: [go-nuts] Re: Stop HTTP Server with Context cancel

2017-04-06 Thread Konstantin Khomoutov
On Thu, 6 Apr 2017 02:04:29 -0700 (PDT) Kemal Hadimli wrote: > Isn't the select processing order random? IIRC the only guarantee is > "default" case is handled as a low priority. > > So, something like this maybe? > > select { > case errCh <- err: > default: > select { > case <-ctx.Done(): > }

[go-nuts] Re: Error handling best practices and unit testing complex error values

2017-04-06 Thread Henry
Use dependency injection and mock the objects to simulate the errors. In my opinion though, there is no need for an error to hold references to its underlying errors. Errors are just values. You take their values, add any additional information, and create a new error. You shouldn't need to tes

[go-nuts] Parsing base64 data with headers

2017-04-06 Thread Ain
Hi I get string which contains: MIME-Version: 1.0 content-type: text/xml content-transfer-encoding: base64 PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPD94bWwtc3R5bGVzaGVldCB0 ... ie there are some headers and then base64 encoded data. I suspect there might be some functions in the st

Re: [go-nuts] Parsing base64 data with headers

2017-04-06 Thread 'chris dollin' via golang-nuts
On 6 April 2017 at 12:00, Ain wrote: > ie there are some headers and then base64 encoded data. I suspect there > might be some functions in the std lib which should be able to parse this > and give me easy access to the headers and data but I just can't find it... > it isn't mime/multipart, righ

Re: [go-nuts] Parsing base64 data with headers

2017-04-06 Thread Ain
neljapäev, 6. aprill 2017 14:07.13 UTC+3 kirjutas ehedgehog: > > On 6 April 2017 at 12:00, Ain > wrote: > > > ie there are some headers and then base64 encoded data. I suspect there > > might be some functions in the std lib which should be able to parse > this > > and give me easy access to t

Re: [go-nuts] Parsing base64 data with headers

2017-04-06 Thread Konstantin Khomoutov
On Thu, 6 Apr 2017 04:00:20 -0700 (PDT) Ain wrote: > I get string which contains: > > MIME-Version: 1.0 > content-type: text/xml > content-transfer-encoding: base64 > > PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPD94bWwtc3R5bGVzaGVldCB0 > ... > > > ie there are some headers and then

[go-nuts] Re: Parsing base64 data with headers

2017-04-06 Thread djadala
https://golang.org/pkg/mime/multipart/ ? On Thursday, April 6, 2017 at 2:00:21 PM UTC+3, Ain wrote: > > Hi > > I get string which contains: > > MIME-Version: 1.0 > content-type: text/xml > content-transfer-encoding: base64 > > > PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPD94bWwtc3R5bGVz

Re: [go-nuts] Parsing base64 data with headers

2017-04-06 Thread Ain
neljapäev, 6. aprill 2017 14:51.13 UTC+3 kirjutas Konstantin Khomoutov: > > On Thu, 6 Apr 2017 04:00:20 -0700 (PDT) > Ain > wrote: > > > > > ie there are some headers and then base64 encoded data. I suspect > > there might be some functions in the std lib which should be able to > > parse thi

Re: [go-nuts] Parsing base64 data with headers

2017-04-06 Thread Konstantin Khomoutov
On Thu, 6 Apr 2017 14:50:43 +0300 Konstantin Khomoutov wrote: > > I get string which contains: [...] > What you're dealing with is a typical set of headers of a so-called > "MIME-formatted" e-mail message followed by its body. The usual set > of headers is missing (those 'From', 'To' etc) and th

Re: [go-nuts] Re: Algorithm Club

2017-04-06 Thread Jesper Louis Andersen
On Fri, Mar 31, 2017 at 6:19 PM Michael Jones wrote: > There is part of the topic that has always been slightly beyond my grasp. > (Maybe I do understand...but just lack absolute certainty.) Maybe others > know the answer... > > In a template system (which is what I prefer but that's not the poin

[go-nuts] Re: Recommended design pattern for real-time monitoring and control of an observatory

2017-04-06 Thread Ron Evans
Allow me to humbly suggest you checkout Gobot https://gobot.io which is intended for this category of application. Disclosure: I am a maintainer of Gobot :) Sincerely, Ron On Thursday, April 6, 2017 at 2:22:15 AM UTC+2, James McHugh wrote: > > I'm writing some software to monitor and control my

[go-nuts] Mapping restricted types to Go

2017-04-06 Thread aconway
I've been reading around on this and I'd like a sanity check on the solution I'm thinking about before I bake it into a public API. The problem: I'm providing a 2 way mapping from Go to another type system (https://godoc.org/qpid.apache.org/amqp for the curious). The specific problem: AMQP allo

[go-nuts] Number of OS threads used by Go runtime

2017-04-06 Thread yuri . shakhmatov
Hi all! Is there any way to count number of OS threads used by Go runtime programmatically (ie without using bash with top/ps and others)? -- Best regards, Yuri -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group an

[go-nuts] Re: Recommended design pattern for real-time monitoring and control of an observatory

2017-04-06 Thread jack
James, Let me suggest the TICK Stack (Written in Go) and Grafana . Its pretty get setup and has much of what you want out of the box. Here is a blog post d

Re: [go-nuts] gomock - why do recorder methods use interface{}?

2017-04-06 Thread Jonathan Yu
Thanks so much for your answer, Julian, that makes total sense! I guess the examples I've seen so far are missing these more "advanced" use cases :) Appreciate the quick and informative reply. On Wed, Apr 5, 2017 at 4:13 PM, Julian Phillips wrote: > On 05/04/2017 18:06, Jonathan Yu wrote: > >>

[go-nuts] [blog post] go tool trace: Golang's hidden trace visualiser

2017-04-06 Thread Will Sewell
Hi, I've just written a blog post/tutorial on Go's relatively unknown, but incredibly useful, trace visualiser: `go tool trace`. The post provides a tour of the interface, and examples of the kind of problems it can aid in tracking down. I was originally made aware of it by Rhys Hiltner in my p

[go-nuts] Re: [blog post] go tool trace: Golang's hidden trace visualiser

2017-04-06 Thread Will Sewell
Apologies. I just realised I didn't actually link to the post! It's here: https://making.pusher.com/go-tool-trace/. On Thursday, 6 April 2017 17:29:22 UTC+1, Will Sewell wrote: > > Hi, I've just written a blog post/tutorial on Go's relatively unknown, but > incredibly useful, trace visualiser: `

Re: [go-nuts] Re: Algorithm Club

2017-04-06 Thread Michael Jones
Thank you for this thoughtful response. It helpful and inspires new thoughts. When I was a boy learning C (1976 or 1977, UNIX 6th Edition at Bell Labs via "learn") the definition of qsort() was a new idea for me. The exposure of base and stride so nakedly (after BASIC and FORTRAN and LISP and SAIL

Re: [go-nuts] Re: [blog post] go tool trace: Golang's hidden trace visualiser

2017-04-06 Thread Rob Pike
That's a great blog post, Will. Thanks for that. The Go team should have provided one for you, I must say, so double thanks. -rob On Thu, Apr 6, 2017 at 10:00 AM, Will Sewell wrote: > Apologies. I just realised I didn't actually link to the post! It's here: > https://making.pusher.com/go-tool-

Re: [go-nuts] What is time.Nanosecond ?

2017-04-06 Thread mpboom2003
Thank you! I get it now. -- 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. For more options, visit https://groups.google.c

Re: [go-nuts] Number of OS threads used by Go runtime

2017-04-06 Thread Ian Lance Taylor
On Thu, Apr 6, 2017 at 3:07 AM, wrote: > > Is there any way to count number of OS threads used by Go runtime > programmatically (ie without using bash with top/ps and others)? Not at present. Perhaps it could be added to the SchedStats proposal (https://golang.org/issue/15490). Ian -- You re

[go-nuts] Re: Number of OS threads used by Go runtime

2017-04-06 Thread Uli Kunitz
I suggest to give n, _ := runtime.ThreadCreateProfile(nil) a try. On Thursday, April 6, 2017 at 5:37:55 PM UTC+2, Юрий Шахматов wrote: > > Hi all! > > Is there any way to count number of OS threads used by Go runtime > programmatically (ie without using bash with top/ps and others)? > > -- > Be

Re: [go-nuts] Re: Number of OS threads used by Go runtime

2017-04-06 Thread Ian Lance Taylor
On Thu, Apr 6, 2017 at 11:18 AM, Uli Kunitz wrote: > I suggest to give n, _ := runtime.ThreadCreateProfile(nil) a try. Good point, yes, that should work. Ian > On Thursday, April 6, 2017 at 5:37:55 PM UTC+2, Юрий Шахматов wrote: >> >> Hi all! >> >> Is there any way to count number of OS threads

[go-nuts] Testing code within channel dispatchers/workers

2017-04-06 Thread Tim Jones
Is there a common pattern for writing tests for workers? I have code that is something like this: type struct Dispatcher{ work chan interface{} moreWork chan interface{} // some other state info stored here } func (d *Dispatcher) Run { for { select { case w := <-work: // Code block 1 //some code

Re: [go-nuts] Thread local error information when wrapping lib with cgo

2017-04-06 Thread Ian Lance Taylor
On Wed, Apr 5, 2017 at 10:32 PM, distributed wrote: > > Thanks for the clarification. I suppose internal UnlockOSThread does not > override the runtime.LockOSThread by my code from the outside? Correct. Ian -- You received this message because you are subscribed to the Google Groups "golang-n

Re: [go-nuts] Bots on the mailing list

2017-04-06 Thread Ian Lance Taylor
On Mon, Apr 3, 2017 at 6:21 PM, Andrew Gerrand wrote: > > As an experiment, I have banned those users from the group. > They can mail us if they have questions about it, at which point we can ask > them what the deal is with the forwarding. > I doubt we will hear from them. > > If anyone sees othe

[go-nuts] Testing code within channel dispatchers/workers

2017-04-06 Thread Tamás Gulácsi
If you really want to test that you write that handful of selects correctly, add the worker blocks as arguments to Run: Run(map[string]func(interface{})) But this way you introdeced another level of indirection, which should be tested. -- You received this message because you are subscribed