[go-nuts] Re: Using "er" and "able" for interfaces

2019-01-16 Thread Roberto Zanotto
Java is object-oriented, Go is subject-oriented :) On Wednesday, January 16, 2019 at 3:42:38 PM UTC+1, Victor Giordano wrote: > > > As far i can get to understand the english language (i'm not a native > speaker), the "er" seems to denotes or describe things in a more "active > way" (the thing

[go-nuts] Re: gob limitation or bug?

2018-11-20 Thread Roberto Zanotto
The encoding/decoding protocol is not stateless: the first time a new type is seen, some type information is transmitted and the Encoder/Decoder objects keep track of that. My guess is that the thing gets messed up by the fact that you are encoding once and decoding twice. I would rewrite your

[go-nuts] Re: Generics are overrated.

2017-07-29 Thread Roberto Zanotto
I love playing with package reflect, which is much more powerful than generics by the way (you can't implement gob or json with generics). On Saturday, July 29, 2017 at 3:28:56 PM UTC+2, M P r a d e s wrote: > > What is overrated is the use of "interface { }" and reflection AKA runtime > magics

[go-nuts] Re: Sorting an array of time.Duration

2017-05-02 Thread Roberto Zanotto
Seems to me that you didn't understand how to use sort, it's a bit different from what you are used to in other languages. Take a look at the examples in the package docs https://golang.org/pkg/sort/#example_ On Tuesday, May 2, 2017 at 8:16:20 PM UTC+2, ramach...@qualtrics.com wrote: > > Hello,

[go-nuts] Re: Map value assignment inside if loop

2017-03-11 Thread Roberto Zanotto
Here's the code on the playground to experiment https://play.golang.org/p/GQG-g84nM2 I believe the problem is at line 9 (and 19, but line 9 is the one we observe). You are using ":=" (short variable declaration) to assign the newly created data, but that does not assign the variable in the

Re: [go-nuts] Re: Wrestling with Mingw64 on Windows

2017-01-30 Thread Roberto Zanotto
Maybe gcc.exe is the 64 version, since you installed mingw64. Have you tried it with cgo? On Monday, January 30, 2017 at 6:31:40 PM UTC+1, Roberto Zanotto wrote: > > That's strange. I'm 100% positive that i686-w64-mingw32 is 32bit > and x86_64-w64-mingw32 is 64bit. > The help mess

Re: [go-nuts] Re: Wrestling with Mingw64 on Windows

2017-01-30 Thread Roberto Zanotto
talled Mingw64 and there are only 2 gcc.exe files: > 1. gcc.exe (seems to be 32 bit) > 2. i686-w64-mingw32-gcc.exe (seems to be 64 bit) > in the help of this one it says: > -m64Generate 64bit x86-64 code. > so must be an x64 compiler ... > > > 2017

[go-nuts] Re: Wrestling with Mingw64 on Windows

2017-01-30 Thread Roberto Zanotto
I suppose the error comes from the fact that you are using the 32bit compiler. *i686*-w64-mingw32-gcc.exe is 32bit, try with x86_64-w64-mingw32-gcc.exe If CC is set correctly, cgo should use that. If you are worried that gcc.exe is being used, temporarily move gcc.exe where cgo can't find it

[go-nuts] x/mobile/gl: blocking vs non-blocking calls

2017-01-26 Thread Roberto Zanotto
Hi. I'm looking at the source of mobile/gl. If I understand correctly, it has a mechanism to reduce the number of cgo calls: the gl calls are accumulated, until a "blocking" call is reached; when that happens, all the calls with associated arguments are passed at once to a C function, which

Re: [go-nuts] can't understand sync.RWMutex documentation

2016-10-31 Thread Roberto Zanotto
, your program can deadlock. On Monday, October 31, 2016 at 1:35:00 PM UTC+1, seaf...@gmail.com wrote: > > I cannot still get it! > Could you explain it to me? > Thanks ahead > > 在 2016年10月4日星期二 UTC+8上午5:28:11,Roberto Zanotto写道: >> >> I get it now. Thanks for your ti

[go-nuts] Re: Loops over sorted array, sort.Sort used as value

2016-10-21 Thread Roberto Zanotto
https://play.golang.org/p/i7l6VAITC1 On Friday, October 21, 2016 at 8:20:38 PM UTC+2, Tong Sun wrote: > > Hi, > > How to loop over sorted array? > > I got "sort.Sort used as value" error: > https://play.golang.org/p/HP30OyJVrz > > Thanks > > -- You received this message because you are

[go-nuts] Re: There has no Mutex.Trylock() implemention or similar method ?

2016-10-21 Thread Roberto Zanotto
Maybe you can solve this with atomics. You keep an int32 that acts as mutex (0 is unocked, 1 is locked), the Trylock is done with atomic.CompareAndSwapInt32(mu, 0, 1) and the Unlock with atomic.StoreInt32(mu, 0). This gives you a Trylock, but you lose the standard (blocking) Lock. You may have

[go-nuts] Re: Proposal: add "future" internal type (similar to channel)

2016-10-17 Thread Roberto Zanotto
I missed the chance to comment on github... This also works for implementing futures and it's simple, type-safe and can be used with select: https://play.golang.org/p/VDT36rC5A- Of course the syntax is not as nice as built-in futures. On Sunday, October 16, 2016 at 2:40:32 PM UTC+2, Sokolov

[go-nuts] Re: Create a new instance by TypeOf

2016-10-15 Thread Roberto Zanotto
gt; Hi, > > I solved it on other group too, a friend help and without remote the > pointer. What you think? > > https://gist.github.com/prsolucoes/2ebc5f199632ba1d72af11b12891d229 > > Thanks. > > On Friday, October 14, 2016 at 11:26:02 PM UTC-3, Roberto Zanotto wrote: &

[go-nuts] Re: Create a new instance by TypeOf

2016-10-14 Thread Roberto Zanotto
The panic you get is because CollectorGoogleAnalytics does not implement ICollector, since GetName is defined on type *CollectorGoogleAnalytics and not CollectorGoogleAnalytics. This works (I changed line 24): https://play.golang.org/p/SIFh3W3qhW On Saturday, October 15, 2016 at 4:02:51 AM

[go-nuts] Re: Increasing memory usage from Gob, references never lost

2016-10-13 Thread Roberto Zanotto
act the references are still being held to the original > decoded object, which is why it stays in memory. I think. > > I will update this post when I learn more/figure it out, but until then if > anyone has more thoughts i'm all ears. > > > On Thursday, October 13, 2016 at

[go-nuts] Re: Increasing memory usage from Gob, references never lost

2016-10-13 Thread Roberto Zanotto
input" channel and retains them?). On Thursday, October 13, 2016 at 10:15:36 PM UTC+2, Roberto Zanotto wrote: > > I took a quick look at the code. There's the Receive loop, you allocate > and decode ReceivedGobs there. As part of the ReceivedGob, a WatheverDevice > is also

[go-nuts] Re: do I need nested maps to have mentioned output. new to golang please help

2016-10-11 Thread Roberto Zanotto
"main" is also the name of the main function, maybe try with a different one. On Tuesday, October 11, 2016 at 11:54:54 PM UTC+2, Dan wrote: > > I need following output > [ > { > date:'2017-07-07', > flags: { > a:1 > b:2 > } > }, > { > date:'2017-07-08', >

Re: [go-nuts] can't understand sync.RWMutex documentation

2016-10-03 Thread Roberto Zanotto
g the lock." > > So if you RLock and then another goroutine tries to Lock, you might > not be able to RLock again until the first read lock is RUnlocked (and > after the Lock+Unlock). > > -Caleb > > On Mon, Oct 3, 2016 at 1:50 PM, Roberto Zanotto <roby...@gmail.com

[go-nuts] can't understand sync.RWMutex documentation

2016-10-03 Thread Roberto Zanotto
Hi everyone. I thought I understood clearly how an RWMutex is supposed to work, but the documentation is giving me some troubles. It says: "The lock can be held by an arbitrary number of readers" which is fine by me, but then the following statement seems to contradict it: "If a goroutine holds

[go-nuts] Re: I want a Gopher Squishable

2016-09-29 Thread Roberto Zanotto
They definitely were on the merchandise store, seems like they're sold out. No idea when they will be available again. Some big Go conferences give them away for free. On Thursday, September 29, 2016 at 8:58:47 PM UTC+2, Esteban Rodríguez Betancourt wrote: > > Hello! > I want to buy a gopher

[go-nuts] Re: How to pass arbitrary typed (int, string, etc) slices to a golang function?

2016-09-24 Thread Roberto Zanotto
If you don't care about preserving the order of the elements in the slice, you can do something like this: https://play.golang.org/p/6QWxWH-Oj7 The functions I used are documented here: https://golang.org/pkg/reflect/ You may want to read this blog post about reflection:

[go-nuts] Re: How to pass arbitrary typed (int, string, etc) slices to a golang function?

2016-09-24 Thread Roberto Zanotto
https://play.golang.org/p/XjcT8wFXVV On Friday, September 23, 2016 at 6:13:04 AM UTC+2, Lax Clarke wrote: > > How would someone create a function like len ? > > func Len(s []interface{}) would not work because compiler complains of > type mismatch if you call it with an integer slice (for

[go-nuts] Re: Reflection: Set the Pointer to Zero Value of Direct Type

2016-09-05 Thread Roberto Zanotto
I should learn to read the questions more carefully before answering -_- In the code you commented out, fd.Type() is a pointer type, so the zero value of a pointer type is a nil pointer. If you do fd.Type().Elem() it gives you the "dereferenced" type of the value. So, maybe you want: v =

[go-nuts] Re: Reflection: Set the Pointer to Zero Value of Direct Type

2016-09-05 Thread Roberto Zanotto
I suppose you want to allocate a new value, since fd is nil: fd = reflect.New(reflect.TypeOf(fd).Elem()) On Monday, September 5, 2016 at 7:28:13 PM UTC+2, dc0d wrote: > > How can I fill a pointer to point to the zero value of underlying type? > > Like in: > > if fd.Kind() == reflect.Ptr { > if

[go-nuts] Re: Strange results from append

2016-07-15 Thread Roberto Zanotto
like to know!), as the solution will be the same regardless. If I need to > always ensure that this will be a different array underneath, I need to > write that code explicitly. > > Thank you, > > Evan > > > > > > > > On Friday, 15 July 2016 10:37:17 UTC

[go-nuts] Re: Strange results from append

2016-07-15 Thread Roberto Zanotto
https://golang.org/pkg/builtin/#append If the initial slice ns has enough capacity, it will not be reallocated, but only resliced and modified in place. So, in your second example, ns1 and ns2 can end up being two slices that share the same underlying array. On Friday, July 15, 2016 at 7:28:32