我尝试通过配置文件(yaml)配置CLI应用程序。该应用程序有几个“组件”(比方说持久层、集成网络服务器等)。这些组件在子包中进行管理,以保持代码整洁。这些组件的配置在它们的包中定义并在配置包中“合并”到表示配置文件的结构。将此代码视为演示实现:packagemainimport("errors""fmt"yaml"gopkg.in/yaml.v2")////Thiswouldbeinpackage'webserver'//OnlytheConfigpartisshown,therewouldbeaconstructorandtheimplementationof//thewebser