mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-14 01:14:37 +00:00
Replace the [slow `goheader` linter](https://github.com/denis-tingaikin/go-header/issues/70) with a custom check. Local go lint time is down from 247s to 32s. 6 new files that were previously undetected because of `//go:build ignore` are fixed. The exit code of the make target preserves the golangci-lint exit code, if present. Also refactors and consolidates the linting targets. Signed-off-by: silverwind <me@silverwind.io> Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Claude (Opus 4.7) <noreply@anthropic.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
42 lines
1.6 KiB
Go
42 lines
1.6 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
//go:build !sqlite_mattn
|
|
|
|
// modernc driver is chosen as the default one (compared to mattn, ncruces)
|
|
// * mattn was used as default, but it requires CGO
|
|
// * the CI times are almost the same for these three (race detector must be disabled)
|
|
// * modernc increases the binary size about 2MB, ncruces increases about 7MB
|
|
// * compiling time: modernc is slightly slower than mattn, ncruces is the slowest
|
|
|
|
package db
|
|
|
|
import (
|
|
"database/sql"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"modernc.org/sqlite"
|
|
)
|
|
|
|
func init() {
|
|
// this driver contains huge amount of Golang code, so it is much slower when "-race" check is enabled.
|
|
registerSQLiteConnStrMaker(makeSQLiteConnStrModerncCCGO)
|
|
sql.Register(sqlDriverSQLite3, &sqlite.Driver{})
|
|
}
|
|
|
|
func makeSQLiteConnStrModerncCCGO(opts SQLiteConnStrOptions) (string, string, error) {
|
|
var params []string
|
|
// TODO: there is a changed behavior from mattn driver:
|
|
// * mattn driver can wait for pretty long time for concurrent accesses (not limited by the busy timeout)
|
|
// * but other drivers will report something like "database is locked (5) (SQLITE_BUSY)" if the timeout is reached
|
|
// Maybe we need to relax the busy timeout to a reasonable long time in the future
|
|
params = append(params, fmt.Sprintf("_pragma=busy_timeout(%d)", opts.BusyTimeout))
|
|
params = append(params, "_txlock=immediate")
|
|
if opts.JournalMode != "" {
|
|
params = append(params, fmt.Sprintf("_pragma=journal_mode(%s)", opts.JournalMode))
|
|
}
|
|
connStr := fmt.Sprintf("file:%s?%s", opts.FilePath, strings.Join(params, "&"))
|
|
return sqlDriverSQLite3, connStr, nil
|
|
}
|