AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
[TOC] > [参考](https://uber-go.github.io/fx/get-started/registration.html) ## 概述 有时候,初始化函数是接口函数 ``` type Route interface { http.Handler // Pattern reports the path at which this is registered. Pattern() string } func (*EchoHandler) Pattern() string { return "/echo" } func NewServeMux(route Route) *http.ServeMux { mux := http.NewServeMux() mux.Handle(route.Pattern(), route) return mux } // main fx.Provide( NewHTTPServer, NewServeMux, fx.Annotate( NewEchoHandler, fx.As(new(Route)), ), zap.NewExample, ), ```