[go-nuts] Pop out first element of a slice.

2016-09-20 Thread Gabriel Adumitrachioaiei
I don't understand something when I want to pop out first element of a slice and use it. Here is my version: s := []int{1,2,3} first := s[0] s = s[1:] Here is a version that I saw in the standard library: https://golang.org/src/database/sql/sql.go#L791 first := s[0] copy(s, s[1:]) s = s[:len(s)

Re: [go-nuts] Pop out first element of a slice.

2016-09-20 Thread Gabriel Adumitrachioaiei
Well, the capacity will be reduced by one. I don't think this makes much difference. On Tuesday, September 20, 2016 at 5:44:20 PM UTC+3, Ian Davis wrote: > > On Tue, Sep 20, 2016, at 03:23 PM, Gabriel Adumitrachioaiei wrote: > > I don't understand something when I want to

Re: [go-nuts] Pop out first element of a slice.

2016-09-20 Thread Gabriel Adumitrachioaiei
M UTC+3, Ian Davis wrote: > > On Tue, Sep 20, 2016, at 03:54 PM, Gabriel Adumitrachioaiei wrote: > > Well, the capacity will be reduced by one. I don't think this makes much > difference. > > > It makes a difference for a long running service that repeatedly pushes

Re: [go-nuts] Pop out first element of a slice.

2016-09-20 Thread Gabriel Adumitrachioaiei
pecific workload. If there is a clear > winner, pick that one. Otherwise, choose either. > In general, I'd indeed assume that for somewhat filled fifo-queues the > append-approach is faster. But I'd be willing to be surprised. > > On Tue, Sep 20, 2016 at 6:03 PM, Ian Davis >

[go-nuts] reflect.ValueOf thread safety

2017-02-27 Thread Gabriel Adumitrachioaiei
I wanted to ask if using reflect.ValueOf concurrently with some other code that makes changes in the memory the pointer references, is thread safe ? For example: type Test struct { name string } var x = &Test{name: "test"} go func() { reflect.ValueOf(&x).MethodByName("SomeMethod").Call(

[go-nuts] Re: reflect.ValueOf thread safety

2017-02-27 Thread Gabriel Adumitrachioaiei
Thanks a lot Dave, I thought that it would be safe but I chose the safe side, and coded as if it is not thread safe. On Monday, February 27, 2017 at 7:34:33 PM UTC, Dave Cheney wrote: > > No, that's is not thread safe. The race detector will spot that. -- You received this message because you

[go-nuts] Re: Delve v1.0.0-rc.1 release

2017-05-08 Thread Gabriel Adumitrachioaiei
Will it be possible to do function calls: https://github.com/derekparker/delve/issues/119 luni, 8 mai 2017, 19:42:43 UTC+1, Derek Parker a scris: > > Hey all, > > Just wanted to make some noise about the latest Delve > release, v1.0.0-rc.1 >