mod: 开发模式下使用工作目录作为数据库目录

This commit is contained in:
unknown-o
2025-12-09 08:55:03 +00:00
parent 6e53bd522e
commit e1818849db

View File

@@ -5,14 +5,21 @@ import (
"ALLinSSL/backend/public/sqlite_migrate"
"database/sql"
"fmt"
_ "modernc.org/sqlite"
"os"
"path/filepath"
"strings"
_ "modernc.org/sqlite"
)
func init() {
// 指定运行目录为当前目录
exePath, err := os.Executable()
// 如果为开发环境则使用工作目录
if strings.Contains(exePath, "go-build") {
exePath, _ = os.Getwd()
}
if err != nil {
fmt.Fprintf(os.Stderr, "获取可执行文件路径失败: %v\n", err)
os.Exit(1)