mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-09-14 14:06:44 +08:00

- 删除460行过度工程代码,替换为273行简洁实现 - 统一三套独立注册系统为单一全局注册表 - 删除app/container.go容器依赖注入系统(107行) - 删除app/initializer.go复杂初始化器(75行) - 删除core/PluginAdapter.go适配器层(82行) - 删除plugins/{services,web,local}/init.go重复代码(238行) - 创建plugins/init.go统一插件接口(116行) - 添加向后兼容适配层保持现有插件不变 架构简化效果: - 代码减少: 460行 → 273行 (减少41%) - 接口统一: 3个Plugin接口 → 1个Plugin接口 - 注册系统: 3套独立系统 → 1套全局系统 - 消除特殊情况,符合'好代码没有特殊情况'原则 编译测试通过,基本功能验证正常
43 lines
853 B
Go
43 lines
853 B
Go
package main
|
||
|
||
import (
|
||
"fmt"
|
||
"os"
|
||
|
||
"github.com/shadow1ng/fscan/common"
|
||
"github.com/shadow1ng/fscan/core"
|
||
|
||
// 导入统一插件系统
|
||
_ "github.com/shadow1ng/fscan/plugins/services"
|
||
_ "github.com/shadow1ng/fscan/plugins/web"
|
||
_ "github.com/shadow1ng/fscan/plugins/local"
|
||
)
|
||
|
||
func main() {
|
||
// Linus式简化:直接执行,删除过度工程
|
||
var info common.HostInfo
|
||
common.Flag(&info)
|
||
|
||
// 初始化日志
|
||
common.InitLogger()
|
||
|
||
// 解析和验证参数
|
||
if err := common.Parse(&info); err != nil {
|
||
handleError("参数解析失败", err)
|
||
}
|
||
|
||
// 初始化输出系统
|
||
if err := common.InitOutput(); err != nil {
|
||
handleError("输出初始化失败", err)
|
||
}
|
||
defer common.CloseOutput()
|
||
|
||
// 执行扫描
|
||
core.RunScan(info)
|
||
}
|
||
|
||
func handleError(msg string, err error) {
|
||
common.LogError(fmt.Sprintf("%s: %v", msg, err))
|
||
os.Exit(1)
|
||
}
|