[go-nuts] Re: Will database/sql leak memory if I don't call Close() and remove references to it?

2016-11-01 Thread Chris Hines
Slight improvement: 1. Rotate usernames/passwords and call sql.Open(...) to get a new connection pool for future queries. (Save old pool in oldDB.) 2. Call oldDB.SetMaxIdleConns(-1), which will immediately close any unused connections in the old pool and cause those in use to be closed as soon a

Re: [go-nuts] Re: Will database/sql leak memory if I don't call Close() and remove references to it?

2016-11-01 Thread Kiki Sugiaman
Bullet proof means a few different things and will depend on other details. It's best to run your own simulation of the edge cases. One I can think of is: what happens if the old pool / db instance opens a new connection during the split second after the credential change at the backend but bef

Re: [go-nuts] Re: type assertion: Can I DRY this up?

2016-11-01 Thread Dan Kortschak
https://github.com/jmoiron/jsonq ? On Tue, 2016-11-01 at 10:13 -0700, wwar...@gmail.com wrote: > Basically, the idea is: given a json structure, and a list of strings > or  > integers, treat the list as a path into the structure and return the > value  > at that point. There are some things this d

[go-nuts] Re: Will database/sql leak memory if I don't call Close() and remove references to it?

2016-11-01 Thread Francis Chuang
Just some further questions. I think the easiest way would be to combine ksug and Chris' suggestions. I would prefer not having to maintain a wrapper for each database as we talk to quite a few different types of databases using database/sql. Does this some bullet proof? 1. Rotate usernames/pas

[go-nuts] Re: Will database/sql leak memory if I don't call Close() and remove references to it?

2016-11-01 Thread Francis Chuang
Hey all, Thanks for the discussion. I've opened https://github.com/golang/go/issues/17727 to see if it might be possible for database/sql to support rotating of username and passwords. As these are currently passed in through the DSN for all drivers, it might be generalized to support changing

RE: [go-nuts] Custom collation

2016-11-01 Thread John Souvestre
I’m thinking that the standard library’s sort would do the job. You would need to supply 3 functions for your data: Len, Swap, and Less. You could implement Less to incorporate your collation scheme. One other idea: Using an array to define the collating order sounds good, but it would re

[go-nuts] Re: [slightly OT] Is this a known virus written in Go?

2016-11-01 Thread Nate Finch
I have definitely heard of more than one virus being written in Go. For some reason, Go programs are just different enough from non-go prorgams, that virus scanners have a hard time categorizing them well, so many just don't try... evidently one of them is going the opposite direction and categ

Re: [go-nuts] [slightly OT] Is this a known virus written in Go?

2016-11-01 Thread Florian Weimer
* Elazar Leibovich: > Hi, > > I'm the author of the goproxy project. > > Recently I received a complaint from a user about goproxy being categorized > as a virus. > > https://www.reasoncoresecurity.com/sysnetwk.exe-fbcc41dafc7bd8cf9b373e0d6b74808b11a9ba3c.aspx > > From a cursory look, it looks li

Re: [go-nuts] Re: type assertion: Can I DRY this up?

2016-11-01 Thread wwarner
Ok! I'm looking at this: https://golang.org/src/encoding/json/encode.go On Tuesday, November 1, 2016 at 1:13:31 PM UTC-4, Nathan Fisher wrote: > > I guess it becomes a question of what operations you want to do on the > data. If you look at the implementation of the Json package and sort > inter

[go-nuts] Re: type assertion: Can I DRY this up?

2016-11-01 Thread wwarner
Basically, the idea is: given a json structure, and a list of strings or integers, treat the list as a path into the structure and return the value at that point. There are some things this doesn't do yet, among them: handle float values, handle slice indexes that are out of range, handle paths

Re: [go-nuts] Re: type assertion: Can I DRY this up?

2016-11-01 Thread Nathan Fisher
I guess it becomes a question of what operations you want to do on the data. If you look at the implementation of the Json package and sort interface it might provide you with some approaches to achieve what you want. Json demonstrates reflection, sort demonstrates how to invert the problem in a wa

[go-nuts] [ANN] go-resty v0.9 release - simple HTTP and REST client library

2016-11-01 Thread Jeevanandam M.
go-resty: https://github.com/go-resty/resty godoc : https://godoc.org/github.com/go-resty/resty This release brings following enhancements: - Backoff Retry mechanism PR #35 #24 @keithballdotnet - Conditional Retry on backoff mechanism PR #42 #37 @d

[go-nuts] Re: type assertion: Can I DRY this up?

2016-11-01 Thread wwarner
https://play.golang.org/p/LhOTUuTVqA On Tuesday, November 1, 2016 at 12:50:09 PM UTC-4, Bill Warner wrote: > > Yes it's just a fragment. Let me clean it up a bit, then I'll share a > playground link. > > On 11/1/16 12:47 PM, Volker Dobler wrote: > > Am Dienstag, 1. November 2016 02:07:49 UTC+1 sc

[go-nuts] Re: type assertion: Can I DRY this up?

2016-11-01 Thread Bill Warner
Yes it's just a fragment. Let me clean it up a bit, then I'll share a playground link. On 11/1/16 12:47 PM, Volker Dobler wrote: Am Dienstag, 1. November 2016 02:07:49 UTC+1 schrieb wwa...@gmail.com: Hello all, I'm new to Go, and I have a question about identifying types as they'r

[go-nuts] Re: type assertion: Can I DRY this up?

2016-11-01 Thread Volker Dobler
Am Dienstag, 1. November 2016 02:07:49 UTC+1 schrieb wwa...@gmail.com: > > Hello all, > > I'm new to Go, and I have a question about identifying types as they're > encountered in traversing a map[string]interface{}. > > I've ended up with a big sieve of type assertions something like this: > >

[go-nuts] [slightly OT] Is this a known virus written in Go?

2016-11-01 Thread Elazar Leibovich
Hi, I'm the author of the goproxy project. Recently I received a complaint from a user about goproxy being categorized as a virus. https://www.reasoncoresecurity.com/sysnetwk.exe-fbcc41dafc7bd8cf9b373e0d6b74808b11a9ba3c.aspx >From a cursory look, it looks like a virus which is using the insec

Re: [go-nuts] Re: zip files created with archive/zip aren't recognised as zip files by java.util.zip

2016-11-01 Thread ndietz
My coworker made a wrapper for writing zip files that are readable by java.util.ZipInputStream, according to the reply given by Alex Skinner. The pkg is on GitHub here . On Tuesday, November 1, 2016 at 1:11:10 AM UTC-7, thebroke...@gmail.com wrote: > > I didn't lo

Re: [go-nuts] type assertion: Can I DRY this up?

2016-11-01 Thread wwarner
@kortschak I guess I see your point. I can list the types in some code, and attach a Get() method to those. But I'm still going to end up with a big ol' switch statement (or if/else block). Seems to me there should be a way to use reflection to pull this off. Thanks --Bill On Monday, October

Re: [go-nuts] Will database/sql leak memory if I don't call Close() and remove references to it?

2016-11-01 Thread Chris Hines
db.SetMaxIdleConns(-1) will flush cached connections. That leaves the problem that open connections still in use will not get closed until returned to the pool, and only if caching idle connections is still disabled at that time. Changing credentials on an already open *sql.DB isn't directly su

[go-nuts] Will database/sql leak memory if I don't call Close() and remove references to it?

2016-11-01 Thread Tamás Gulácsi
As *database/sql.DB is a connection pool, maybe you have to go deeper, and implement a driver by wrapping a mtsql driver. This is not hard, as a driver.Driver is a narrow interface. This way you can do as you wish, and close old connections (you can account for them), or just do the password chan

Re: [go-nuts] Function passing fails to perform type coercion to interface

2016-11-01 Thread Ian Lance Taylor
On Tue, Nov 1, 2016 at 6:54 AM, Steven Hartland wrote: > > It seems that even though the returned type matches the interface within the > function argument go doesn't do the coercion needed to make this happen, > instead if errors: > cannot use NewMyType (type func() (*MyType, error)) as type func

Re: [go-nuts] Idea for versioning in the new Go package manager.

2016-11-01 Thread Sean Russell
Hi, On Wednesday, October 26, 2016 at 4:42:13 AM UTC-4, Axel Wagner wrote: > > I thought about this too, but came to the conclusion that this would first > require a good definition of what "API breakage" actually means. > > In it's strictest interpretation as "any go package that imports this w

Re: [go-nuts] Will database/sql leak memory if I don't call Close() and remove references to it?

2016-11-01 Thread Daniel Theophanes
I think there is a larger issue at play of how old connections are cached and handled. In particular there is no way to flush cached connections or update credentials in the API. Could you file an issue with how to best update credentials on an existing connection pool? -- You received this m

[go-nuts] gomobile - error building android library on osx

2016-11-01 Thread Danilo Luiz Rheinheimer Danilo
Hi, I have a gomobile library project. I can build it to android on my linux machine. On my macbook (osx) I am able to build the iOS version. But I am not able to build the android version on OSX. Gomobile version : Danilos-MacBook-Pro:mobileutildemo danilolr$ gomobile version gomobile

Re: [go-nuts] Function passing fails to perform type coercion to interface

2016-11-01 Thread Pietro Gagliardi
This does not work for the same reason []*MyType cannot be converted to []MyInterface or even to []interface{}: the in-memory representation of an interface is not the same as of the concrete type. See also https://golang.org/doc/faq#convert_slice_of_interface > On Nov 1, 2016, at 6:54 AM, Steve

[go-nuts] Function passing fails to perform type coercion to interface

2016-11-01 Thread Steven Hartland
I was playing with a design today where I had a number of types which match an interface and was surprised that I couldn't make use of this fact in passing their new functions into a method. It seems that even though the returned type matches the interface within the function argument go doesn

Re: [go-nuts] Will database/sql leak memory if I don't call Close() and remove references to it?

2016-11-01 Thread Kiki Sugiaman
database/sql does not specify what gets freed before calling Close(). If the driver or the database server happen to release resources on their own, that is incidental and should not be relied upon unless you have deep knowledge of the driver and the database behavior. You can schedule Close()

[go-nuts] Re: Will database/sql leak memory if I don't call Close() and remove references to it?

2016-11-01 Thread Daniel Theophanes
If you open DB with db.Open, yes, you will need to call db.Close(). Without that it will keep alive a pool of connections to your remote database. -Daniel On Monday, October 31, 2016 at 10:33:06 PM UTC-7, Francis Chuang wrote: > > I want to use Vault to manag

Re: [go-nuts] Re: Float32 math and slice arithmetics using SIMD

2016-11-01 Thread Ondrej
Klaus, that's a great thread, completely missed it. It seems that a universal binary, as Go requires it, would be slow on dispatch, because there would be too much checking for individual intrinsics support. Do I understand it correctly, that to overcome this, people either compile natively (wh

Re: [go-nuts] Re: zip files created with archive/zip aren't recognised as zip files by java.util.zip

2016-11-01 Thread thebrokentoaster
I didn't look into this deeply, but if there's something strange that Go's implementation of zip is doing, feel free to file an issue. It's too late for anything to happen in Go 1.8, but I can investigate it deeper in Go 1.9. JT On Saturday, October 29, 2016 at 9:05:08 AM UTC-7, JohnGB wrote: >