[go-nuts] Re: Shuffle Items in a Slice

2016-06-27 Thread Chris Hines
The history of this behavior is explained in the release notes for Go 1.3: https://golang.org/doc/go1.3#map On Friday, June 24, 2016 at 8:48:20 AM UTC-4, Val wrote: > > 2 implementations here : > http://www.programming-idioms.org/idiom/10/shuffle-a-list/1564/go > > As for the map iteration

[go-nuts] Re: Can somebody explain the importance of 'select'?

2017-01-19 Thread Chris Hines
I believe the primary reason why select must be in the language is because it integrates tightly with goroutine scheduling to efficiently block, and then wake up when one of its channel operations can complete. On Thursday, January 19, 2017 at 12:33:38 PM UTC-5, John C. wrote: > > On several

Re: [go-nuts] runtime.Caller ->

2016-08-16 Thread Chris Hines
There was some discussion about how to handle generated methods in stack traces in #11432, in particular I brought it up in this comment: https://github.com/golang/go/issues/11432#issuecomment-146269822. The discussion eventually led to the addition of the new runtime.CallersFrames API, but

[go-nuts] Re: Why is there no " declared and not used" compile error?

2016-09-14 Thread Chris Hines
On Monday, September 12, 2016 at 8:57:15 AM UTC-4, Markus Zimmermann wrote: > > Hi gophers! > > I am wondering why we have a "declared and not used" compile error for > variables [https://play.golang.org/p/KLzHVO5L7q] but not for constants [ > https://play.golang.org/p/JG9dSa_VKg]? I am sure

[go-nuts] do packages need to be recompiled when Go is upgraded?

2016-09-28 Thread Chris Hines
I'm pretty sure that the last few versions of Go (since 1.5 maybe) are smart enough to do it automatically. I believe the .o files in the pkg tree have the compiler version embedded in their meta data for this purpose. -- You received this message because you are subscribed to the Google

[go-nuts] Re: Interface vs first-class function

2016-11-20 Thread Chris Hines
I tried to break down the thought process on this exact question earlier this year and gave a presentation at my local Go meetup. My slides are here: http://go-talks.appspot.com/github.com/ChrisHines/talks/non-orthogonal-choices-in-go/non-orthogonal-choices-in-go.slide

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

Re: [go-nuts] Context cancellation

2016-11-03 Thread Chris Hines
FWIW, I'm a big fan of gopkg.in/tomb.v2. For similar functionality using contexts consider golang.org/x/sync/errgroup. On Wednesday, November 2, 2016 at 7:55:59 PM UTC-4, Gustavo Niemeyer wrote: > > You said the function would return whether it got cancelled or not, so I > assumed something

[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

Re: [go-nuts] Function pointer vs interface for callback?

2016-10-13 Thread Chris Hines
If you want to dig into this topic more. I gave a presentation on this topic at my local Go meetup earlier this year. The slides from my talk are here: http://go-talks.appspot.com/github.com/ChrisHines/talks/non-orthogonal-choices-in-go/non-orthogonal-choices-in-go.slide#1 Some of the code

[go-nuts] Re: error when json unmarshaling string to type string

2016-12-15 Thread Chris Hines
142 > var i2 = float64(3.142) > i3 := float64(3.142) > > The float64 casting is unnecessary in the latter two cases, but it isn't > an error. > > On Thursday, 15 December 2016 21:01:11 UTC+5:30, Chris Hines wrote: >> >> Suppose instead of `json:"s,string"` you had

[go-nuts] Re: error when json unmarshaling string to type string

2016-12-15 Thread Chris Hines
Suppose instead of `json:"s,string"` you had typed `json:"s,omitemptyy"` when you meant to type `json:"s,omitempty"`. Would you want to be told that you had an error in your struct tag? In general Go has a fail-fast philosophy to help prevent mistakes from persisting in a system unnoticed for

[go-nuts] Re: Isn't the use of Context in db/sql non-diomatic?

2016-12-12 Thread Chris Hines
I agree with the sentiment that putting these options in context.Context values is inappropriate. Chris On Friday, December 9, 2016 at 7:14:03 PM UTC-5, Dave Cheney wrote: > > I agree with this. This feels like a case of abusing the "bag of values" > nature of context's Value() feature to

Re: [go-nuts] Cross compiling from Windows to Linux produces non-working go routines

2017-03-08 Thread Chris Hines
The infinite loops in each function will busy loop and consume a core without allowing the runtime scheduler a chance to run other goroutines on that core. If your virtual machine doesn't have enough cores then some goroutines may starve. Change the loops to select {} to block infinitely

Re: [go-nuts] Built-in log Package

2017-08-15 Thread Chris Hines
kage. That said, designing private libraries as if they were public libraries could be a good idea in the long run. Chris On Tuesday, August 15, 2017 at 12:09:44 PM UTC-4, Sam Vilain wrote: > > On 8/15/17 7:14 AM, Chris Hines wrote: > > I would be curious what you think o

Re: [go-nuts] Built-in log Package

2017-08-15 Thread Chris Hines
I would be curious what you think of github.com/go-kit/kit/log (and related "sub"-packages). See my talk about it's design here: Video: https://youtu.be/ojhFQNgyZO4?list=FLcxNiie7-UD8znndwDn7PFw Slides: https://speakerdeck.com/chrishines/go-kit-log-package Chris On Monday, August 14, 2017 at

[go-nuts] Re: Go Styleguide

2017-08-01 Thread Chris Hines
The code shown for "User decorator pattern" is more properly known as the "Functional options" pattern. I think this talk demonstrates the decorator pattern more correctly: https://www.youtube.com/watch?v=xyDkyFjzFVc On Monday, July 31, 2017 at 12:15:18 PM UTC-4, ha...@arne.me wrote: > > Hey, I

Re: [go-nuts] Go Styleguide

2017-08-01 Thread Chris Hines
This discussion points out another nomenclature problem in the list. What the list refers to as a "Package comment" is actually a "Canonical import path" comment. See https://golang.org/doc/go1.4#canonicalimports Package comments (as defined in this blog post:

Re: [go-nuts] Built-in log Package

2017-08-17 Thread Chris Hines
On Thursday, August 17, 2017 at 3:14:09 AM UTC-4, Henrik Johansson wrote: > > Sorry to but in but what happened to the whole logging initiative that was > on going? > Did I miss something about that? It seems very related to this. > That discussion took place in this thread:

[go-nuts] Re: Go's scheduler always “stuck” after certain time when executing the code below

2017-06-21 Thread Chris Hines
See also: https://github.com/golang/go/issues/10958 On Wednesday, June 21, 2017 at 1:12:12 AM UTC-4, Ronald wrote: > > I found this: https://github.com/golang/go/issues/7190. > > Then I replace : > > go func() { > for { > } > }() > > With: > > > go func() { > ct := 0 >

[go-nuts] Re: Open Source audit of go package dependencies for security vulnerabilities?

2019-08-15 Thread Chris Hines
Have you seen: https://github.com/sonatype-nexus-community/nancy "A tool to check for vulnerabilities in your Golang dependencies, powered by Sonatype OSS Index" On Wednesday, August 14, 2019 at 1:02:03 AM UTC-4, Eric Johnson wrote: > > And then, it also occurs to me that perhaps I can answer

[go-nuts] Re: how to create path/v2 and path/v3 and path/v4 in same repo

2019-08-27 Thread Chris Hines
You might be able to find an answer to your question in this article: https://github.com/go-modules-by-example/index/tree/master/016_major_version_repo_strategy On Tuesday, August 27, 2019 at 6:31:57 AM UTC-4, Jason E. Aten wrote: > > With an eye towards implementing semantic import path