我们知道在根模块提供程序中,我们可以APP_INITIALIZER在后端设置引导某些依赖项,然后加载第一个组件
{
provide: APP_INITIALIZER,
useFactory: configLoader,
multi: true,
deps: [ConfigService]
}
Run Code Online (Sandbox Code Playgroud)
我将以上述方式在应用程序启动之前加载我的用户配置,但我想做更多的事情,比如在我的应用程序启动之前连接websocket.
我知道我可以在configLoader我编写的函数中执行,首先加载配置然后在该configLoader函数中连接websocket,但由于某些原因,我现在不能这样做,所以我需要在某种程度上这样做:
{
provide: APP_INITIALIZER,
useFactory: [configLoader, websocketLoader],
multi: true,
deps: [ConfigService, WebsocketService]
}
Run Code Online (Sandbox Code Playgroud)
但不幸的是,它不会起作用.那么有没有办法加载多个应用程序初始化程序?
我在我的应用程序中使用一些 aws-sdk-go 功能,它会创建要请求的 DNS 样式主机,例如somebucket.mys3.com. 但我有一些 DNS 问题,并且希望以路径样式接收请求,例如mys3.com/somebucket. 如何配置 SDK 以路径样式模式生成请求?
我安装了一些jsonnet格式化插件,重新启动IDE后,它卡在GoLand启动映像上。
我还通过终端打开了 GoLand /Applications/GoLand.app/Contents/MacOS/goland,它显示了关于具有相同文件格式的两个插件的一些例外情况:
Caused by: com.intellij.diagnostic.ImplementationConflictException: Language with ID 'Jsonnet' is already registered: class com.jsonnetplugin.JsonnetLanguage
.
.
.
ERROR - llij.ide.plugins.PluginManager - Plugin to blame: Jsonnet Language Server version: 0.0.5
Run Code Online (Sandbox Code Playgroud)
有没有办法在没有 GoLand 本身的情况下禁用插件(例如配置文件或参数),以便我可以让 IDE 再次运行?
当我使用Unmarshalviper 的方法用 yaml 文件中的值填充我的配置结构时,一些结构字段变成了空!我这样做:
viper.SetConfigType("yaml")
viper.SetConfigName("config")
viper.AddConfigPath("/etc/myapp/")
viper.AddConfigPath(".")
err := viper.ReadInConfig()
// error checking ...
conf := &ConfYaml{}
err = viper.Unmarshal(conf)
// error checking ...
Run Code Online (Sandbox Code Playgroud)
我的结构是这样的:
type ConfYaml struct {
Endpoints SectionStorageEndpoint `yaml:"endpoints"`
}
type SectionStorageEndpoint struct {
URL string `yaml:"url"`
AccessKey string `yaml:"access_key"`
SecretKey string `yaml:"secret_key"`
UseSSL bool `yaml:"use_ssl"`
Location string `yaml:"location"`
}
Run Code Online (Sandbox Code Playgroud)
这里url和location字段在 yaml 文件中填充了正确的值,但其他字段为空!
很想知道当我尝试打印如下字段时:
viper.Get("endpoints.access_key")
Run Code Online (Sandbox Code Playgroud)
它在 yaml 文件中打印正确的值并且不为空!