-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
add grpc example #1401
add grpc example #1401
Conversation
examples/grpc/gin/main.go
Outdated
|
||
// Set up a http setver. | ||
r := gin.Default() | ||
r.GET("/rest/n/:name", func(g *gin.Context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe change g *gin.Context
to c *gin.Context
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thanks.
vendor/vendor.json
Outdated
"path": "google.golang.org/grpc", | ||
"revision": "9cb02b885b41e0db982e23d6e51a24ea465dec2e", | ||
"revisionTime": "2017-06-26T23:20:44Z" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't update the vendor source code from example code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, but if have not this, ci will fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and I have removed it.
examples/grpc/pb/helloworld.pb.go:23:2: cannot find package "google.golang.org/grpc" in any of:
/home/travis/gopath/src/github.com/gin-gonic/gin/vendor/google.golang.org/grpc (vendor tree)
/home/travis/.gimme/versions/go1.6.4.linux.amd64/src/google.golang.org/grpc (from $GOROOT)
/home/travis/gopath/src/google.golang.org/grpc (from $GOPATH)
make: *** [test] Error 1 |
@thinkerou ignore check |
examples/grpc/gin/main.go
Outdated
c.JSON(http.StatusOK, gin.H{ | ||
"result": fmt.Sprint(res.Message), | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe updated as the following for readable.
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"error": err.Error(),
})
return
}
c.JSON(http.StatusOK, gin.H{
"result": fmt.Sprint(res.Message),
})
Codecov Report
@@ Coverage Diff @@
## master #1401 +/- ##
=======================================
Coverage 97.99% 97.99%
=======================================
Files 36 36
Lines 1848 1848
=======================================
Hits 1811 1811
Misses 30 30
Partials 7 7 Continue to review full report at Codecov.
|
if err != nil { | ||
c.JSON(http.StatusInternalServerError, gin.H{ | ||
"error": err.Error(), | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing return
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, thanks a lot, fixed.
@appleboy thank you update |
@thinkerou Can you also help to remove packages from example? |
@appleboy OK, I will alone commit one pull request for coding review. |
code indent error, fixed. |
use grpc helloworld example.