-
Notifications
You must be signed in to change notification settings - Fork 1
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
Joe #12
base: master
Are you sure you want to change the base?
Joe #12
Conversation
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.
Just some comments about a couple of things I'm curious about
|
||
func get_id(params martini.Params, w http.ResponseWriter) (int, 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.
nit: elsewhere you used camel case 😄
w.Write(jsonStr) | ||
book, err := datastoreQuery.GetById(id) | ||
if err != nil { | ||
internalErrorRendor(err, w) |
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.
typo?
w.Write(jsonStr) | ||
book, err := datastoreQuery.GetById(id) | ||
if err != nil { | ||
internalErrorRendor(err, w) |
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.
typo?
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.
as in spelling mistake? then yes probably got a few in there. Or is something else?
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.
I was wondering if you really intended Rendor
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.
ah no I wanted to intentionally highlight we were erroring out here instead of just rendoring. Although yes the Rendor method does take an err
and can return an error message.
// work for that model. The alternative would be to write some templating code but that would be | ||
// a mess. | ||
t := reflect.TypeOf(models.Book{}) | ||
for i := 0; i < t.NumField(); i++ { |
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.
what's the advantage of using the reflection api with respect to a more traditional approach - meaning if else
to build the query? And more, can this be easily tweaked to filter by different params at the same time?
// work for that model. The alternative would be to write some templating code but that would be | ||
// a mess. | ||
t := reflect.TypeOf(models.Book{}) | ||
for i := 0; i < t.NumField(); i++ { |
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.
what's the advantage of using the reflection api with respect to a more traditional approach - meaning if else
to build the query? And more, can this be easily tweaked to filter by different params at the same time?
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.
The advantage is that you get to automatically update the filtering when the struct changes. That was the main benefit.
But also it was a question of could I try and find a solution that allowed that to be possible as well.
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.
which makes sense, but you still filter one parameter at a time am I right?
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.
I allowed it so that you can filter by more than one parameter which might have been outside of the spec. And I think if you were only doing one parameter you would go with the if statement approach probably.
"github.com/stretchr/testify/require" | ||
) | ||
|
||
type TestTuple struct { |
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.
nice one 👍
"github.com/stretchr/testify/require" | ||
) | ||
|
||
type TestTuple struct { |
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.
nice one 👍
@@ -1,11 +1,13 @@ | |||
module acme-books | |||
|
|||
go 1.17 | |||
go 1.16 |
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.
why the downgrade?
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.
https://pendo-io.atlassian.net/wiki/spaces/ENG/pages/188336/Go+Setup I checked this and updated my local install but I think it must have automatically changed that to go with it
@@ -1,11 +1,13 @@ | |||
module acme-books | |||
|
|||
go 1.17 | |||
go 1.16 |
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.
why the downgrade?
|
||
func get_id(params martini.Params, w http.ResponseWriter) (int, 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.
nit: elsewhere you used camel case 😄
w.Write(jsonStr) | ||
book, err := datastoreQuery.GetById(id) | ||
if err != nil { | ||
internalErrorRendor(err, w) |
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.
I was wondering if you really intended Rendor
// work for that model. The alternative would be to write some templating code but that would be | ||
// a mess. | ||
t := reflect.TypeOf(models.Book{}) | ||
for i := 0; i < t.NumField(); i++ { |
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.
which makes sense, but you still filter one parameter at a time am I right?
No description provided.