[go-nuts] Re: defer at struct level

2016-08-21 Thread 'Eric Johnson' via golang-nuts
On Sunday, August 21, 2016 at 3:04:02 PM UTC-7, Asit Dhal wrote: > > Hi all, > I use defer to release resource at function level. > > func test() { > a := A.Open() > defer a.Close() > //other code > } > > I need the object a, to be wrapped in a struct. Can someone tell me how to > make

Re: [go-nuts] Are receivers from a channel fifo?

2016-08-21 Thread 'Kevin Malachowski' via golang-nuts
Try it out :) seems like a simple enough test program to write. -- 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

[go-nuts] defer at struct level

2016-08-21 Thread 'Kevin Malachowski' via golang-nuts
Do you have a code sample? I don't quite understand what you mean by something being "wrapped" in a struct. Will 'a' be a field in a struct? If so, you can just access it: defer myStructValue.a.Close() -- You received this message because you are subscribed to the Google Groups "golang-nuts"

Re: [go-nuts] Why doesn't type T satisfy the Equal interface?

2016-08-21 Thread Gbr
On Sunday, August 21, 2016 at 5:50:52 PM UTC-7, Axel Wagner wrote: > > Yes. When you save A in a variable (or parameter) of type C, the compiler > emits code to create an interface value and puts a pointer to A in it > (together with a dispatch table for the interface functions, AIUI). But >

[go-nuts] inconsistent behaviour of rate.Limiter.WaitN

2016-08-21 Thread Manlio Perillo
The documentation of rate.Limiter.WaitN function says that it blocks until lim permits n events to happen and that it returns an error if n exceeds the Limiter's burst size. However the documentation of rate.Limiter type says that, as a special case, if rate limit is Inf, burst size is ignored.

Re: [go-nuts] Are receivers from a channel fifo?

2016-08-21 Thread Steven Hartland
On 21/08/2016 21:51, Jan Mercl wrote: On Sun, Aug 21, 2016, 22:43 Steven Hartland > wrote: If I have multiple goroutines reading from a channel are they guaranteed to be FIFO i.e. is the handler that requested the read first

[go-nuts] defer at struct level

2016-08-21 Thread asit dhal
Hi all, I use defer to release resource at function level. func test() {   a := A.Open()   defer a.Close()   //other code } I need the object a, to be wrapped in a struct. Can someone tell me how to make a.Close() in this case elegantly ? Warm Regards, Asit Dhal http://bit.ly/193ASIT -- You

Re: [go-nuts] Why doesn't type T satisfy the Equal interface?

2016-08-21 Thread Gbr
I had deleted the question, planning on expanding before reposting, On Sunday, August 21, 2016 at 12:00:51 PM UTC-7, Axel Wagner wrote: > > I think if you want this to happen (you're far from the first, there is > even a github-issue, AFAIK, but I'm too lazy to find it right now) you also

Re: [go-nuts] Are receivers from a channel fifo?

2016-08-21 Thread Jan Mercl
On Sun, Aug 21, 2016, 22:43 Steven Hartland wrote: > If I have multiple goroutines reading from a channel are they guaranteed > to be FIFO i.e. is the handler that requested the read first guaranteed to > get the first value, second to get the second and so on? > > Values

[go-nuts] Are receivers from a channel fifo?

2016-08-21 Thread Tamás Gulácsi
No. See what a select statement says about order when multiple cases are choosable: not defined, and the implementation guarantees uniform randomness -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

[go-nuts] Are receivers from a channel fifo?

2016-08-21 Thread Steven Hartland
If I have multiple goroutines reading from a channel are they guaranteed to be FIFO i.e. is the handler that requested the read first guaranteed to get the first value, second to get the second and so on? Regards Steve -- You received this message because you are subscribed to the

Re: [go-nuts] expvar when not using global mux

2016-08-21 Thread Hugh Emberson
You can access the global mux as 'http.DefaultServeMux' and since a mux is a 'http.Handler' you can add it to another mux like this: myMux.Handle("/debug/", http.DefaultServeMux) On Sun, Aug 21, 2016 at 10:46 AM, Amit Upadhyay wrote: > expvar registers expvarHandler as

[go-nuts] expvar when not using global mux

2016-08-21 Thread Amit Upadhyay
expvar registers expvarHandler as init(), which registers it to global mux. This is convenient in general. In my app I have a non global mux, and I have no way to register it. In case of net/http/pprof the handlers are exported. I have ended up copying expvarHandler() in my project. Should I

Re: [go-nuts] gophercon 2016 videos

2016-08-21 Thread Nyah Check
Way to go. +KelseyHightower. Cheers! -- 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

Re: [go-nuts] Re: Understanding go routine heap

2016-08-21 Thread Henrik Johansson
Yes like Jan previously said. It is the very use case WaitGroup was developed for. On Sun, Aug 21, 2016, 15:45 T L wrote: > > > On Saturday, August 20, 2016 at 2:29:41 PM UTC+8, Yulrizka wrote: >> >> Dear gophers >> >> I have discussion with my colleague about this code >>

[go-nuts] context: testing if an HTTP request was canceled

2016-08-21 Thread Manlio Perillo
I writing a simple HTTP client using the new context support in Go 1.7. I need to test it in case a timeout is specified and expires, but I'm having problems. The context package defines the Cancel error variable, that is returned by Context.Err when the context is canceled. However the

[go-nuts] Re: Understanding go routine heap

2016-08-21 Thread T L
On Saturday, August 20, 2016 at 2:29:41 PM UTC+8, Yulrizka wrote: > > Dear gophers > > I have discussion with my colleague about this code > > > func process() *foo { > var result *foo > > var wg sync.WaitGroup > wg.Add(1) > go func() { > defer wg.Done() > result

Re: [go-nuts] Language Feature Proposal: define

2016-08-21 Thread Henry
Uh oh. You're right. Thanks for reminding me. Somehow I missed that. -- 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.

[go-nuts] Language Feature Proposal: define

2016-08-21 Thread Henry
Hi, I think some aspects of Go language are rather verbose to the extent that they hurts readability. For instance, let's take closures. The following is a bit hard to read: func MyFunction(rows *sql.Rows, parser func(raw *sql.Rows) ([]MyData, error )) ([]MyData,error){ ... } It would be

Re: [go-nuts] Cross compilation to see assembly outputs with go tool compile

2016-08-21 Thread jose . vazquez
Thanks, that worked too! On Sunday, August 21, 2016 at 1:20:47 AM UTC+1, Aram Hăvărneanu wrote: > > You might also be interested in > > GOOS=linux GOARCH=arm go build -gcflags='-S' foo > > or > > GOOS=linux GOARCH=arm go build -gcflags='-S' -asmflags='-S' foo > > -- > Aram Hăvărneanu