kivanc10 / golang-rest-api-with-mysql Goto Github PK
View Code? Open in Web Editor NEWA Go rest API project that is following solid and common principles and is connected to local MySQL database.
A Go rest API project that is following solid and common principles and is connected to local MySQL database.
Followed your Reddit link and took a look; your Reddit post there did not ask for suggestions but, having scanned your dbOp
package I do have a few so thought raising an issue might be the best way to communicate (feel free to ignore/delete this). I've only looked at the dbOp
package:
sql.Open
with every call. Consider doing this once at startup (as the docs say "...the Open function should be called just once. It is rarely necessary to close a DB."). sql.DB
will reuse connections (and establish new ones where needed) which avoids the cost that comes with establishing lots of connections.defer rows.Close()
when running a query (this is called automatically when rows.Next()
returns false but you may not always fully read the rows e.g. GetLastLoginToken
). Also consider checking for errors - rows.Err()
sql.Prepare
is really only adds value when you will be running the same statement multiple times (with different parameters).error
more often; its nice to be able to let the end user know when something has gone wrong (and calling panic
when, for example, the username is not found will not work in production).reqBody []byte
) and parse it; this does not really seem to fit within the database package (a significant part of the rationale for having a separate package is that there may be other users and these might not accept JSON). A common approach is to have a model
package.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.