feat(bookmark): 实现书签和文件夹的增删改查功能 - 添加 GetFolderDefaultRoot 方法用于获取默认根文件夹 - 实现 bookmark 和 folder 的请求/模型/响应转换函数 - 完善 CreateBookmark、CreateFolder、DeleteBookmark、DeleteFolder 等接口逻辑 - 支持删除空文件夹,非空文件夹禁止删除 - 修复根文件夹创建逻辑并添加错误处理 - 删除未实现的示例路由和无用代码 build: 引入 mage 构建工具支持多平台编译 - 添加 magefile.go 实现跨平台构建脚本 - 更新 go.mod 和 go.sum 引入 github.com/magefile/mage 依赖 - 在 README 中补充 mage 使用说明和 VSCode 配置 docs: 更新 README 并添加 mage 使用示例 - 添加 govulncheck 和 mage 构建相关文档 - 补充 VSCode gopls 配置说明 ci: 更新 .gitignore 忽略 bin 目录和可执行文件 - 添加 bin/ 到忽略列表 - 统一忽略 *.exe 和 *.sqlite3 文件 refactor(main): 优化主函数启动逻辑与日志输出 - 移除示例 helloworld 路由 - 设置 gin 为 ReleaseMode 模式 - 统一服务监听地址为变量,并增加启动日志提示 ```
82 lines
1.7 KiB
Go
82 lines
1.7 KiB
Go
//go:build mage
|
|
// +build mage
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
|
|
"github.com/magefile/mage/mg" // mg contains helpful utility functions, like Deps
|
|
)
|
|
|
|
// Default target to run when none is specified
|
|
// If not set, running mage will list available targets
|
|
// var Default = Build
|
|
|
|
// A build step that requires additional params, or platform specific steps for example
|
|
// Build builds the application for multiple platforms.
|
|
func Build() error {
|
|
mg.Deps(InstallDeps)
|
|
|
|
// Define target platforms
|
|
platforms := []struct {
|
|
OS string
|
|
Arch string
|
|
}{
|
|
{"linux", "amd64"},
|
|
{"linux", "arm64"},
|
|
{"darwin", "amd64"},
|
|
{"darwin", "arm64"},
|
|
{"windows", "amd64"},
|
|
}
|
|
|
|
for _, p := range platforms {
|
|
fmt.Printf("Building for %s/%s...\n", p.OS, p.Arch)
|
|
|
|
// Set environment variables for cross-compilation
|
|
env := append(os.Environ(),
|
|
fmt.Sprintf("GOOS=%s", p.OS),
|
|
fmt.Sprintf("GOARCH=%s", p.Arch))
|
|
|
|
// Determine output name
|
|
outputName := fmt.Sprintf("./bin/zzyxyz_go_api-%s-%s", p.OS, p.Arch)
|
|
if p.OS == "windows" {
|
|
outputName += ".exe"
|
|
}
|
|
|
|
// Run build command
|
|
cmd := exec.Command("go", "build", "-o", outputName, ".")
|
|
cmd.Env = env
|
|
|
|
if err := cmd.Run(); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// A custom install step if you need your bin someplace other than go/bin
|
|
func Install() error {
|
|
mg.Deps(Build)
|
|
// fmt.Println("Installing...")
|
|
// return os.Rename("./MyApp", "/usr/bin/MyApp")
|
|
return nil
|
|
}
|
|
|
|
// Manage your deps, or running package managers.
|
|
func InstallDeps() error {
|
|
fmt.Println("Installing Deps...")
|
|
// cmd := exec.Command("go", "get", "github.com/stretchr/piglatin")
|
|
// return cmd.Run()
|
|
return nil
|
|
}
|
|
|
|
// Clean up after yourself
|
|
func Clean() {
|
|
fmt.Println("Cleaning...")
|
|
// os.RemoveAll("MyApp")
|
|
}
|