[go-nuts] How go-mysql-driver get data? "get all data at a time" or "only get a batch when we call rows.Next"?

2019-06-26 Thread
When we operate with mysql with Go, as follow: rows, err := db.Query() for rows.Next() { . } When the driver get data? Get all data at once when we call `Query`??? Or only get a batch of Data when we call `Next`, and get next batch of data when we run out of it -- You

[go-nuts] How can stop a Read of net.Conn without closing it

2019-06-04 Thread
When there is no data in tcp connection, net.Conn.Read will block. Then I want to cancel the net.Conn.Read from another goroutine, But I do not want to close the connection, Because I will reuse it latter. How to write the code??? For example: func (p *proxy) toClient(ctx

Re: [go-nuts] How can I read private field in go struct instance

2019-06-03 Thread
ere are packages already available for this. > > > > github.com/kortschak/utter (for Go syntax-like printing) > > github.com/davecgh/spew (for less Go syntax-like printing) > > > > > > > > On Mon, 2019-06-03 at 08:54 -0700, 杜沁园 wrote: >

[go-nuts] How can I read private field in go struct instance

2019-06-03 Thread
I recently write a program to recursively print all fields and value in a struct. Interface() is the most convinence way to get underlying value in go. But it will panic when field is private.How can I access private field? For simple type, I can stil use Int(),Bool(),etc to read private