使用kratos框架的项目demo
使用kratos工具工具生成
go get -u github.com/bilibili/kratos/tool/kratos
cd $GOPATH/src
kratos new kratos-demo
a project that use kratos
you should commit client demo,so that is easy use it
`kratos tool protoc --grpc --bm api.proto
2020/04/15 17:33:32 protoc --proto_path=/Users/jelty/data/GoPath/src --proto_path=/Users/jelty/data/GoPath/pkg/mod/github.com/go-kratos/[email protected]/third_party --proto_path=/Users/jelty/data/GoPath/src/kratos-demo/api --bm_out=:. api.proto
api.proto: File does not reside within any path specified using --proto_path (or -I). You must specify a --proto_path which encompasses this file. Note that the proto_path must be an exact prefix of the .proto file names -- protoc is too dumb to figure out when two paths (e.g. absolute and relative) are equivalent (it's harder than you think).
exit status 1
exit status 1
kratos tool genbts
Close: 无声明 忽略此方法
Ping: 无声明 忽略此方法
dao.bts.go: 生成成功
kratos tool genmc
mc.cache.go: 生成成功
kratos tool wire
wire: /Users/jelty/data/GoPath/src/kratos-demo/internal/service/service.go:15:33: first argument to Bind must be a pointer to an interface type; found
wire: kratos-demo/internal/di: generate failed
wire: at least one generate failure
exit status 1
kratos tool wire
wire: kratos-demo/internal/dao: wrote /Users/jelty/data/GoPath/src/kratos-demo/internal/dao/wire_gen.go
Project: kratos-demo
OnlyGRPC: false
OnlyHTTP: false
Directory: /Users/jelty/data/GoPath/src/kratos-demo
项目创建成功.`
jelty@jeltydeMBP:~/data/GoPath/src/kratos-demo/cmd|
⇒ go build
../api/client.go:15:68: undefined: DemoClient
../api/client.go:21:9: undefined: NewDemoClient
for {
s := <-c
log.Info("get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
ctx, cancel := context.WithTimeout(context.Background(), 35*time.Second)
defer cancel() //这里
grpcSrv.Shutdown(ctx)
httpSrv.Shutdown(ctx)
log.Info("kratos-demo exit")
svc.Close()
time.Sleep(time.Second)
return
case syscall.SIGHUP:
default:
return
}
改成
for {
s := <-c
log.Info("get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
func(){
ctx, cancel := context.WithTimeout(context.Background(), 35*time.Second)
defer cancel()
httpSrv.Shutdown(ctx)
log.Info("kratos-demo exit")
svc.Close()
time.Sleep(time.Second)
}()
return
case syscall.SIGHUP:
default:
return
}
}
这样idea就不会报warning了
能提供更多的client的例子,客户端A调用B服务的那种
protoc。也安装了,但是还是不行啊
如题
Module path is inconsistent with go import path.
GO111MODULE=on, run go get -u github.com/bilibili/kratos/tool/kratos
:
go: downloading github.com/bilibili/kratos v0.5.0
go: found github.com/bilibili/kratos/tool/kratos in github.com/bilibili/kratos v0.5.0
go get: github.com/bilibili/[email protected]: parsing go.mod:
module declares its path as: github.com/go-kratos/kratos
but was required as: github.com/bilibili/kratos
module github.com/bilibili/kratos
go 1.13
require (
…
)
go version:1.13.4
go env:
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/skymac/Library/Caches/go-build"
GOENV="/Users/skymac/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/skymac/sky_work/go_work"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.google.cn"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/skymac/sky_work/go_work/src/kratos-demo/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/6w/7vfbqgyj2klckr8kyzqfj40c0000gn/T/go-build759567413=/tmp/go-build -gno-record-gcc-switches -fno-common"
go build 报错
../api/client.go:15:68: undefined: DemoClient
../api/client.go:21:9: undefined: NewDemoClient
go get 获取的是v0.3.1,请问怎么获取master(Go 新手,请多指教)
把DAO,Model,rpc client使用多给点例子?
(总不能叫我对这go-common学吧)
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.