Timeout for calling the QueryRow method using the database / sql package in the Golang

What is a suitable way to implement a timeout for calling a method QueryRowusing a package database/sqlin Golang? There was a lot of discussion on this topic, and I like to know if there is a solution / best practice in golang 1.7 other than using the package contextas described here:

Ability to timeout when loading a connection from the pool

In addition, it seems that contextual support has been implemented recently . What would be the appropriate way to use context for timeout connections?

+4
source share

Source: https://habr.com/ru/post/1656900/


All Articles