Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

database/sql: update SetMaxIdleConns documentation to specify the default value #22138

pjebs opened this issue Oct 5, 2017 · 4 comments


Copy link

@pjebs pjebs commented Oct 5, 2017

Can the team please update the documentation for SetMaxIdleConns to specify what the default value should be.

I fell into a trap in here:
where the the struct I used will set SetMaxIdleConns to 0 (which is the zero-value of an int).

It turns out that intended default value is 2, but the documentation does not state that.

Also on a separate issue:
I don't think defaultMaxIdleConns const is actually used properly in the code. I suspect it is a bug.

Copy link

@andizzle andizzle commented Oct 5, 2017

Can we have a test check here in sql_test to check the maxIdle value after Open() is called.

func TestMaxIdleConns(t *testing.T) {
	db := newTestDB(t, "people")
	defer closeDB(t, db)

        if db.maxIdle != defaultMaxIdleConns {
		t.Errorf("default max idle = %d; want %d", db.maxIdle, defaultMaxIdleConns)

	tx, err := db.Begin()
@odeke-em odeke-em changed the title SetMaxIdleConns(n int) issue database/sql: update SetMaxIdleConns documentation to specify the default value Oct 5, 2017
Copy link

@odeke-em odeke-em commented Oct 5, 2017

@kardianos kardianos self-assigned this Oct 31, 2017
Copy link

@kardianos kardianos commented Oct 31, 2017

I didn't get to it in time for go1.10. I'll think about this for go1.11.

@ianlancetaylor ianlancetaylor added this to the Go1.11 milestone Mar 29, 2018
Copy link

@gopherbot gopherbot commented Apr 20, 2018

Change mentions this issue: database/sql: add additional Stats to DBStats

@gopherbot gopherbot closed this in d89ea41 May 11, 2018
@golang golang locked and limited conversation to collaborators May 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.