新增书签服务主程序,使用 Gin 框架搭建 HTTP 服务器,并注册书签相关接口处理器。 配置 CORS 中间件以支持跨域请求。服务监听端口为 8081。 feat(user_np): 初始化用户权限服务并注册认证接口 新增用户权限服务主程序,使用 Gin 框架搭建 HTTP 服务器,并注册登录、注册及修改密码等接口处理器。 服务监听端口为 8082。 refactor(config): 重构 OpenAPI 配置文件结构并拆分模块 将原有合并的 OpenAPI 配置文件按功能模块拆分为 bookmark 和 user_np 两个独立目录, 分别管理各自的 server、client 及 API 定义文件,便于后续维护和扩展。 refactor(vfs): 调整虚拟文件系统 API 接口路径与参数定义 更新 VFS API 配置文件,修改部分接口路径及参数结构, 如将文件路径参数由 path 转为 query 参数,并优化响应结构体定义。
71 lines
1.5 KiB
Go
71 lines
1.5 KiB
Go
//go:build mage
|
|
// +build mage
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
// 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
|
|
|
|
func BuildAll() error {
|
|
services := []struct {
|
|
Name string
|
|
Path string
|
|
}{
|
|
{"openapi", "."},
|
|
{"bookmark", "./cmd/bookmark"},
|
|
{"user_np", "./cmd/user_np"},
|
|
}
|
|
|
|
platforms := []struct {
|
|
OS string
|
|
Arch string
|
|
}{
|
|
{"linux", "amd64"},
|
|
{"windows", "amd64"},
|
|
}
|
|
|
|
for _, service := range services {
|
|
for _, p := range platforms {
|
|
fmt.Printf("Building service %s for %s/%s...\n", service.Name, p.OS, p.Arch)
|
|
|
|
// 设置环境变量
|
|
env := append(os.Environ(),
|
|
fmt.Sprintf("GOOS=%s", p.OS),
|
|
fmt.Sprintf("GOARCH=%s", p.Arch))
|
|
|
|
// 确定输出名称
|
|
outputName := fmt.Sprintf("./bin/%s/%s-%s-%s", p.OS, service.Name, p.OS, p.Arch)
|
|
if p.OS == "windows" {
|
|
outputName += ".exe"
|
|
}
|
|
|
|
// // 执行构建命令
|
|
// cmd := exec.Command("go", "build", "-o", outputName, service.Path)
|
|
// cmd.Env = env
|
|
|
|
// 使用 release 模式构建并显示链接信息
|
|
cmd := exec.Command("go", "build",
|
|
"-x",
|
|
"-ldflags", "-s -w -extldflags -static", // 去除调试信息,减小体积
|
|
"-v", // 显示编译过程中的包信息
|
|
"-o", outputName,
|
|
service.Path)
|
|
cmd.Env = env
|
|
|
|
if err := cmd.Run(); err != nil {
|
|
return fmt.Errorf("failed to build %s: %w", service.Name, err)
|
|
}
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|