wangzhongyang007 / goframe-shop-v2 Goto Github PK
View Code? Open in Web Editor NEW基于goframev2最新版本开发
基于goframev2最新版本开发
需要 go get github.com/Shopify/sarama
文件路径:internal/mq/kafka/kafka.go
这里有报错
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)
}
}
}
如题。注意到这个项目里并没有加任何测试。如果考虑到测试的话,这样的架构business层和数据层的测试不就耦合在一起了吗?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.