Re: [go-nuts] will GC close unused connection ?

2017-02-16 Thread caspian46
Thanks! I'm going to read it carefully. 在 2017年2月16日星期四 UTC+8下午4:40:54,Konstantin Khomoutov写道: > > On Thu, 16 Feb 2017 00:29:04 -0800 (PST) > casp...@gmail.com wrote: > > > > > Will GC close unused connection ? > > > > > > No. At least not directly. A finalizer can possibly do that and > > >

Re: [go-nuts] will GC close unused connection ?

2017-02-16 Thread caspian46
Many thanks! Yes, I know that it is wrong to keep connection without call Close func. just when I working on a bug, I found the connection was closed automatically somehow. 在 2017年2月16日星期四 UTC+8下午4:33:54,Axel Wagner写道: > > Yes, in general, the GC will usually close connections when the > corre

Re: [go-nuts] will GC close unused connection ?

2017-02-16 Thread caspian46
Thanks for you reply! Means yes, GC will close unused connection, just indirectly? Cause I found this: #/opt/go/src/net/fd_unix.go func (fd *netFD) setAddr(laddr, raddr Addr) { fd.laddr = laddr fd.raddr = raddr runtime.SetFinalizer(fd, (*netFD).Close) } And this function

[go-nuts] will GC close unused connection ?

2017-02-15 Thread caspian46
Will GC close unused connection ? In a particular case, I found that if there's a connection won't be used for a while, it will be closed. If I disable GC, then the connection will not be closed. In the test, I never call the close function manually. But this is a bit hard to reproduce. GC will

[go-nuts] Re: encoding/gob decode []byte to multi struct types

2017-01-18 Thread caspian46
Thanks for you reply, I got it done: https://play.golang.org/p/oOEELLyaVv This is how I did it, pass *interface{} to gob.Encode, not interface{} the same with gob.Decode, then get the type info from the decoded value interface{} 在 2017年1月18日星期三 UTC+8下午10:51:51,Jordan Krage写道: > > Actually, it

[go-nuts] Re: encoding/gob decode []byte to multi struct types

2017-01-17 Thread caspian46
First thanks for you reply. Because in fact, I have about more than 10 different struct types (maybe more and more), your suggest is good, this is better type Info struct{ typeStr string // store the type info to decode IData IData interface{} } But I don't like to send the typeInfo thro

[go-nuts] encoding/gob decode []byte to multi struct types

2017-01-17 Thread caspian46
I got two struct types encoded into bytes by gob, I want to decode the bytes into a specific struct, is it possible without try all struct types(maybe 3 or more struct types)? I want to decode bytes without specify which elem in mixedBytes is struct A, and which is struct B. This is the playgr