You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When i took a look at dbstat struct, I realized that all the type of field assigned int or string, not pointer.
Is there any problem that change fields of DBstat struct to pointer value?
If it assigned pointer value, it seems like can collect database metric information in real time.
The text was updated successfully, but these errors were encountered:
As mentioned by @seankhliao, db.Stats() should be called at the point when you are ready to collect the data. It should not be able to mutate the state of DB.
I'm going to close this issue since this is working as expected. Please feel free to follow up if this was done in error.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Purpose: I want to get database metric information in go application.
So here is a source code.
db, err := sql.Open("postgres", connectionInfo)
dbstat := db.Stats()
db.SetMaxOpenConns(20)
fmt.Println(dbstat.MaxOpenConnections)
What did you expect to see?
I expected the printed number is 20
What did you see instead?
The result of the code was 0 (default value)
When i took a look at dbstat struct, I realized that all the type of field assigned int or string, not pointer.
Is there any problem that change fields of DBstat struct to pointer value?
If it assigned pointer value, it seems like can collect database metric information in real time.
The text was updated successfully, but these errors were encountered: