I wrote a simple token based authentication api and was wondering if someone would want to have
a look at it and see if I made some mistakes or if I could improve some other things.
I was also wondering how I could best implement user input validation (I never did that before).
Furthermore I wasn’t sure if I QueryRow prepares the statements and then executes it. Does someone
know that by any chance? Otherwise I would change QueryRow to Prepare and then Exec.
I can’t tell you if your code does what you think it should do because there is no documentation telling me what you think it should do or how one is expected to interact with it. There are also no tests.
I was also wondering how I could best implement user input validation (I never did that before).
The “best” way depends on your specific requirements. Start by figuring out what is valid and what is not. Then write some tests, then write some Go that passes the tests.
Furthermore I wasn’t sure if I QueryRow prepares the statements and then executes it. Does someone
know that by any chance? Otherwise I would change QueryRow to Prepare and then Exec.
Does your code with QueryRow work? If yes, leave it alone. If no, fix it.