1. docker-compose 搭建etcd
https://www.jianshu.com/p/44022c67f117/
2. docker-compose 搭建redis mysql
git@github.com:brady-wang/service.git
git clone && cd service && docker-compose up -d
3 bookstore
http://zero.gocn.vip/zero/bookstore.html#_11-%E5%AE%8C%E6%95%B4%E8%B0%83%E7%94%A8%E6%BC%94%E7%A4%BA
DataSource: root:123456@tcp(192.168.1.99:3306)/gozero
例子没有写密码
最终启动四个窗口
─mac@macdeMacBook-Pro /www/go/bookstore/rpc/add ‹master*› ╰─$ go run add.go -f etc/add.yaml ─mac@macdeMacBook-Pro /www/go/bookstore/rpc/check ‹master*› ╰─$ go run check.go -f etc/check.yaml ─mac@macdeMacBook-Pro /www/go/bookstore ‹master*› ╰─$ go run bookstore.go -f etc/bookstore-api.yaml 第四个调用 存储 ╭─mac@macdeMacBook-Pro /www/go/bookstore ‹master*› ╰─$ curl -i "http://localhost:8888/add?book=php&price=24" HTTP/1.1 200 OK Content-Type: application/json Date: Sun, 21 Feb 2021 02:54:34 GMT Content-Length: 11 {"ok":true}% 查找 ╭─mac@macdeMacBook-Pro /www/go/bookstore ‹master*› ╰─$ curl -i "http://localhost:8888/check?book=php" HTTP/1.1 200 OK Content-Type: application/json Date: Sun, 21 Feb 2021 02:59:21 GMT Content-Length: 25 {"found":true,"price":24}%
查看数据库已有值了