Giter VIP home page Giter VIP logo

Comments (6)

printfcoder avatar printfcoder commented on June 27, 2024

你好,这个需要在配置文件里激活Mysql配置
才会在配置方法里初始化

from stack-rpc-tutorials.

linbo avatar linbo commented on June 27, 2024

激活了,但是跑的时候panic了,initMysql没有返回连接会有问题吧

from stack-rpc-tutorials.

printfcoder avatar printfcoder commented on June 27, 2024

不会,看是不是配置没有初始化,main函数里初始化了没。initMysql会把config中的私有变量mysql赋值,而不是返回

	// 初始化配置、数据库等信息
	basic.Init()

from stack-rpc-tutorials.

linbo avatar linbo commented on June 27, 2024

initMysql是执行了,而且也连接了,但是db.go:GetDB()返回nil,感觉db.go:mysqlDB 没有被初始化

from stack-rpc-tutorials.

printfcoder avatar printfcoder commented on June 27, 2024

哪个示例?方便的话进slack沟通,进入后进入**区,或私聊我

from stack-rpc-tutorials.

linbo avatar linbo commented on June 27, 2024

代码写错了

https://github.com/micro-in-cn/tutorials/blob/master/microservice-in-micro/part1/user-srv/basic/db/mysql.go#L14

写成

mysqlDB, err := sql.Open("mysql", config.GetMysqlConfig().GetURL())

from stack-rpc-tutorials.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.