mirror of
https://gitee.com/mirrors/AllinSSL.git
synced 2026-03-07 23:31:10 +08:00
mod: 开发模式下使用工作目录作为数据库目录
This commit is contained in:
@@ -5,14 +5,21 @@ import (
|
|||||||
"ALLinSSL/backend/public/sqlite_migrate"
|
"ALLinSSL/backend/public/sqlite_migrate"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
_ "modernc.org/sqlite"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
_ "modernc.org/sqlite"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// 指定运行目录为当前目录
|
// 指定运行目录为当前目录
|
||||||
exePath, err := os.Executable()
|
exePath, err := os.Executable()
|
||||||
|
|
||||||
|
// 如果为开发环境则使用工作目录
|
||||||
|
if strings.Contains(exePath, "go-build") {
|
||||||
|
exePath, _ = os.Getwd()
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "获取可执行文件路径失败: %v\n", err)
|
fmt.Fprintf(os.Stderr, "获取可执行文件路径失败: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user