我正在尝试使用sarama(管理员模式)创建主题。如果没有ConfigEntries,则可以正常运行。但是我需要定义一些配置。
我设置了主题配置(这里发生了错误):
tConfigs := map[string]*string{
"cleanup.policy": "delete",
"delete.retention.ms": "36000000",
}
Run Code Online (Sandbox Code Playgroud)
但是然后我得到一个错误:
./main.go:99:28: cannot use "delete" (type string) as type *string in map value
./main.go:100:28: cannot use "36000000" (type string) as type *string in map value
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用这样的管理模式:
err = admin.CreateTopic(t.Name, &sarama.TopicDetail{
NumPartitions: 1,
ReplicationFactor: 3,
ConfigEntries: tConfigs,
}, false)
Run Code Online (Sandbox Code Playgroud)
这是sarama模块中定义CreateTopic()的代码行, 网址为https://github.com/Shopify/sarama/blob/master/admin.go#L18
基本上,我不了解指针字符串的映射是如何工作的:)