Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Joe #12

wants to merge 1 commit into from

Conversation

JosephLing
Copy link
Collaborator

No description provided.

@JosephLing JosephLing marked this pull request as ready for review March 21, 2022 11:48
@JosephLing JosephLing requested a review from wildeng March 21, 2022 11:48
@JosephLing JosephLing changed the title first attempt (not all tested though) Joe Mar 21, 2022
Copy link

@wildeng wildeng left a 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) {
Copy link

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)
Copy link

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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

Copy link
Collaborator Author

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?

Copy link

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

Copy link
Collaborator Author

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++ {
Copy link

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++ {
Copy link

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?

Copy link
Collaborator Author

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.

Copy link

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?

Copy link
Collaborator Author

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 {
Copy link

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 {
Copy link

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the downgrade?

Copy link
Collaborator Author

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
Copy link

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) {
Copy link

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)
Copy link

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++ {
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants