FAQ
Yes, I looked at that, it explains how to delete from a slice - isn't that
what I'm doing in my code<https://github.com/mindplay-dk/riot.go/blob/master/observable.go#L75>
?

So I just set up a brand new Go 1.2.1 on my new computer tonight, and
checked out my code and ran it - and now, what should be two calls, and was
3 calls on my other system, generates 5 calls on this system!

Could somebody run the test on their setup and compare the output?

=== RUN TestObservable
--- FAIL: TestObservable (0.00 seconds)
observable_test.go:23: LoadEvent handler #1: LoadEvent#1
observable_test.go:30: LoadEvent handler #2: LoadEvent#1
observable_test.go:37: SaveEvent once-handler #1: SaveEvent#1
observable_test.go:44: SaveEvent handler: SaveEvent#1
observable_test.go:44: SaveEvent handler: SaveEvent#2
observable_test.go:55: SaveEvent once-handler #2: SaveEvent#3
observable_test.go:44: SaveEvent handler: SaveEvent#3
observable_test.go:30: LoadEvent handler #2: LoadEvent#2
observable_test.go:30: LoadEvent handler #2: LoadEvent#2
observable_test.go:30: LoadEvent handler #2: LoadEvent#3
observable_test.go:30: LoadEvent handler #2: LoadEvent#3
observable_test.go:76: expected 2 calls to LoadEvent handler #2, got 5
FAIL
exit status 1
FAIL github.com/mindplay-dk/riot 0.512s

Meanwhile, I am none the wiser, and slice deletion, as explained on the
wiki (and here) doesn't make a lick of sense to me.

It's making me feel pretty dumb. This must be the first and least idiomatic
thing I've seen in Go so far - an operation this basic should not make you
feel dumb, and should not require code that is, more or less, void of any
semantics.

I love the simplicity of Go, but this doesn't seem simple at all - it seems
unnecessarily complicated, and I'm more than a a little taken aback by
this... :-/

Any better alternatives - or any hope of this improving in the future?

Thanks,
   Rasmus
On Tuesday, March 18, 2014 7:14:42 AM UTC-5, Matthew Zimmerman wrote:

https://code.google.com/p/go-wiki/wiki/SliceTricks
On Tue, Mar 18, 2014 at 7:45 AM, Carlos Castillo wrote:
Example: http://play.golang.org/p/DiwQ7XF3oP
On Tuesday, March 18, 2014 4:39:26 AM UTC-7, Carlos Castillo wrote:

The slice (list) that's being pulled out of the map on line #71 is not
being assigned back into the map, so it still has the original slice
bounds
(when removing should have shortened it), as a result the last element
is
duplicated.

You should assign the list back to the map before breaking.
On Monday, March 17, 2014 8:39:21 AM UTC-7, Rasmus Schultz wrote:

Is it working differently if I'm deleting the last item in a slice?

I posted the whole thing here:

https://github.com/mindplay-dk/riot.go


On Sun, Mar 16, 2014 at 11:10 PM, Ross Salas wrote:

Works here too. I deleted item 5. You may want to check value of
listener.id.

http://play.golang.org/p/2NqcLNLBqu


On Sun, Mar 16, 2014 at 8:56 PM, Dan Kortschak
wrote:
Works here http://play.golang.org/p/WNd9wmkq9c

--
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...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
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...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/d/optout.
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 10 of 30 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMar 17, '14 at 3:34a
activeMar 20, '14 at 3:25a
posts30
users14
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase