---
title: "A linter I really recommend you to use if you're doing SQL in Golang"
description: "The sqlclosecheck linter catches unclosed sql.Rows and sql.Stmt objects in Go code, which otherwise can cause deadlocks or inefficient disk use in databases like SQLite."
url: "https://swe.quest/articles/a-linter-i-really-recommend-you-to-use-if-you-re-doing-sql-in-golang-01ce20ff247e64a5"
canonical: "https://turso.tech/blog/a-linter-i-really-recommend-you-to-use-if-youre-doing-sql-in-golang-ab9fcf5b561f"
source: "Turso"
published: "2023-08-10"
difficulty: "medium"
kind: "How-to"
reading_minutes: 3
tags: ["go","static-analysis","ci-cd","sql"]
---

# A linter I really recommend you to use if you're doing SQL in Golang

A post on [Turso](https://swe.quest/sources/turso.md), published 2023-08-10, 3 min read, How-to. Original: [https://turso.tech/blog/a-linter-i-really-recommend-you-to-use-if-youre-doing-sql-in-golang-ab9fcf5b561f](https://turso.tech/blog/a-linter-i-really-recommend-you-to-use-if-youre-doing-sql-in-golang-ab9fcf5b561f)

## Summary

The sqlclosecheck linter catches unclosed sql.Rows and sql.Stmt objects in Go code, which otherwise can cause deadlocks or inefficient disk use in databases like SQLite. A short example shows it flagging a missing rows.Close() and passing once defer rows.Close() is added. It can be added to CI as a GitHub Actions step via go vet -vettool, or enabled in golangci-lint through .golangci.yaml, and is recommended as a standard CI check.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Go](https://swe.quest/tags/go.md) (Languages)
- [Static analysis](https://swe.quest/tags/static-analysis.md) (Engineering practices)
- [CI/CD](https://swe.quest/tags/ci-cd.md) (Reliability & operations)
- [SQL](https://swe.quest/tags/sql.md) (Languages)

## Prerequisites

- Go database/sql package ([easy posts on Go](https://swe.quest/tags/go.md?difficulty=easy))
- GitHub Actions basics ([easy posts on CI/CD](https://swe.quest/tags/ci-cd.md?difficulty=easy))

## Keywords

sqlclosecheck, database/sql, golangci-lint, GitHub Actions, go vet, SQLite

## Related posts

- [Something you probably want to know about if you're using SQLite in Golang](https://swe.quest/articles/something-you-probably-want-to-know-about-if-you-re-using-sqlite-in-golang-998bba3901e282c7.md): Turso · 2023-08-03 · Medium · 5 min read · SQLite, Go, Storage engines, Debugging
  In SQLite's WAL mode, an unclosed Go database/sql rows object keeps a read transaction open, which stops checkpoints from moving changes from the WAL file into the main database file.
- [How to get your database access code deadlocked in Golang](https://swe.quest/articles/how-to-get-your-database-access-code-deadlocked-in-golang-f01f82ad269b4372.md): Turso · 2023-07-27 · Medium · 5 min read · Go, Concurrency, Debugging, Databases
  In Go's database/sql, failing to close a Rows result can deadlock the program when a loop over query results returns early on error.
- [How we used Quint to find over 10 bugs in SQLite while hardening Turso](https://swe.quest/articles/how-we-used-quint-to-find-over-10-bugs-in-sqlite-while-hardening-turso-43686794db9fa980.md): Turso · 2026-05-18 · Medium · 5 min read · Formal methods, SQLite, Testing, Databases
  Modeling individual SQLite C API contracts in Quint, generating small traces, and replaying them as C programs against real SQLite uncovered more than 10 SQLite bugs while also validating Turso's compatible C API.
- [Data needs its DevOps moment](https://swe.quest/articles/data-needs-its-devops-moment-d7c45f88ee69de4f.md): Render · 2026-10-08 · Medium · 9 min read · Stream processing, Data pipelines, Observability, Debugging, Memory management
  Data pipelines should be treated like any other production service: defined as code in the producing team's repo, with portable SQL logic tested in CI, and run 24x7 against SLOs for lag, freshness and completeness.
- [We’re All Just Looking for Connection](https://swe.quest/articles/we-re-all-just-looking-for-connection-b10700c8e0417e48.md): Slack Engineering · 2024-10-10 · Medium · 7 min read · Python, Networking, Debugging, Concurrency, Incidents & postmortems
  Spikes of EOFError on SQL queries in Quip's Python backend (which also powers Slack canvas) traced back to connection-state checks that only tracked closes initiated by the application.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
