Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/mq/kafka/kafka.go有报错了 #13

Open
liliewin opened this issue Apr 20, 2023 · 4 comments
Open

internal/mq/kafka/kafka.go有报错了 #13

liliewin opened this issue Apr 20, 2023 · 4 comments

Comments

@liliewin
Copy link

liliewin commented Apr 20, 2023

文件路径:internal/mq/kafka/kafka.go
这里有报错
image

func init() {
	mq, err := g.Cfg().Get(gctx.New(), "mq")
	if err != nil {
		panic(err)
	}
	ip := mq.Map()["kafka"].(string) // 这里有报错
	pool := []string{ip}
	builder := NewKafkaBuilder(pool)
	kafkaPool := NewKafkaPool().SetBuilder(builder)
	err = kafkaPool.Init()
	if err != nil {
		fmt.Println("初始化kafka失败:", err.Error())
		os.Exit(1)
	}
}

改成

func init() {
	mq, err := g.Cfg().Get(gctx.New(), "mq")
	if err != nil {
		panic(err)
	}
	if ip, ok := mq.Map()["kafka"].(string); ok {  //  改
		pool := []string{ip}
		builder := NewKafkaBuilder(pool)
		kafkaPool := NewKafkaPool().SetBuilder(builder)
		err = kafkaPool.Init()
		if err != nil {
			fmt.Println("初始化kafka失败:", err.Error())
			os.Exit(1)
		}
	}
}
@wangzhongyang007
Copy link
Owner

wangzhongyang007 commented Apr 20, 2023 via email

@canyonwan
Copy link
Contributor

直接提pr啊

@liliewin
Copy link
Author

liliewin commented Jun 8, 2023 via email

@wangzhongyang007
Copy link
Owner

wangzhongyang007 commented Jun 8, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants