diff --git a/go.mod b/go.mod index c3635a3..d32911e 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/go-chi/render v1.0.2 github.com/joho/godotenv v1.5.1 github.com/mattn/go-isatty v0.0.17 + github.com/mattn/go-sqlite3 v1.14.9 github.com/nektos/act v0.0.0 github.com/sirupsen/logrus v1.9.0 github.com/spf13/cobra v1.6.1 diff --git a/internal/app/artifactcache/db_cgo.go b/internal/app/artifactcache/db_cgo.go new file mode 100644 index 0000000..fcaf04f --- /dev/null +++ b/internal/app/artifactcache/db_cgo.go @@ -0,0 +1,11 @@ +// Copyright 2023 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +//go:build cgo +// +build cgo + +package artifactcache + +import _ "github.com/mattn/go-sqlite3" + +var sqliteDriverName = "sqlite3" diff --git a/internal/app/artifactcache/db_nocgo.go b/internal/app/artifactcache/db_nocgo.go new file mode 100644 index 0000000..ce83d85 --- /dev/null +++ b/internal/app/artifactcache/db_nocgo.go @@ -0,0 +1,11 @@ +// Copyright 2023 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +//go:build !cgo +// +build !cgo + +package artifactcache + +import _ "modernc.org/sqlite" + +var sqliteDriverName = "sqlite" diff --git a/internal/app/artifactcache/handler.go b/internal/app/artifactcache/handler.go index 2e063fc..478b84b 100644 --- a/internal/app/artifactcache/handler.go +++ b/internal/app/artifactcache/handler.go @@ -19,7 +19,6 @@ import ( "github.com/go-chi/chi/v5/middleware" "github.com/go-chi/render" log "github.com/sirupsen/logrus" - _ "modernc.org/sqlite" "xorm.io/builder" "xorm.io/xorm" ) @@ -56,7 +55,7 @@ func StartHandler(dir, outboundIP string, port uint16) (*Handler, error) { return nil, err } - e, err := xorm.NewEngine("sqlite", filepath.Join(dir, "sqlite.db")) + e, err := xorm.NewEngine(sqliteDriverName, filepath.Join(dir, "sqlite.db")) if err != nil { return nil, err }