mirror of
https://github.com/allinssl/allinssl.git
synced 2025-12-12 09:44:09 +08:00
mod: 开发模式下使用工作目录作为数据库目录
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user