Go-bootstrap: Generates a lean and mean Go web project
go-bootstrap.io
go-bootstrap.io
Hmm, maybe I should go through the common Ruby frameworks and add a section like this in a pull request...
The project is aimed at getting up to speed as fast as possible, and the docs is geared towards that.
Take a look at [1]. Congratulations, you've written an ORM.
The belief that ORMs are evil is precisely the belief that this sort of code should be repeated everywhere database access is performed. If you have generalized routines for interacting with the database with more comfortable abstractions then string concatenation, you are using an ORM, but possibly a poorly tested, poorly documented homegrown one instead of a generally accepted solution that has more eyes on it. You are what you claim to be above.
Which is not bad, lightweight ORM is awesome. You could also debate terminology that these are not really objects, but the spirit is still pretty similar to activerecord and sqlalchemy.
[1]https://github.com/go-bootstrap/go-bootstrap/blob/master/bla...
> Object-Relational Mapping tools provide data layers in this fashion, following the active record model. The ORM/active-record model is popular with web frameworks.
:D
This is incorrect.
The sqlx library, included in OP, has generalized routines for interacting with the database, but is not an ORM. The squirrel[1] library for Go lets you produce queries without "string concatenation", but is also very much not an ORM.
An ORM is a specific style of library that attempts to map object oriented data patterns to relational concepts. That's why it's called an Object-Relational Mapping. There are good reasons[2] why people find this approach problematic, which aren't down to cargo culting them as "evil" or believing that everyone should repeat data access code in all projects.
[1]http://github.com/lann/squirrel [2]http://en.wikipedia.org/wiki/Object-relational_impedance_mis...
When you claim that you are not using an ORM, a reasonable person would take it to mean that you are forgoing the use of query builders and automated mapping from SQL results to application data structures.
So, it may be true that classifying these libraries as ORMs is incorrect, but the "user experience" as a developer between these libraries and typical ORMs appears to be pretty much the same. Or is that unfair?
AR/Django encourage you to describe your entire schema, _including_ the relationships between tables, as attributes on your model objects. Upon doing this, you get simple and reliable programmatic access to some basic access and storage patterns.
Using this knowledge of your data model, the ORM can now provide you with more advanced tools: it can automatically join across tables (`select_related`), lazily load dependent data[1], generate SQL schema for you, transparently cache queries[2], automatically provide HTML form validators, and even automate database schema migration for you. The more completely you model the system, the more it can do for you.
In these systems, the database is subservient to the model. This is a problem, because the database is reality and the model is a model.
Dropping to "opaque SQL strings" is discouraged, both because it's considered error prone ("You should leave SQL to the professionals! There are lots of eyes on this!") and because there is often no graceful way to integrate custom query code with your model layer; instead, you investigate how to do so within the confines of the ORM. For every case where you can eventually find what you need (`select_related("user__friends__email")`), there are a dozen where you can't.
People start writing things in application code that could be handled easily and more efficiently by the database: aggregations are a classic, since ORMs support is either missing or incredibly complex. As soon as the application becomes non-trivial[3], the problems magnify. They don't do this because they are stupid, or bad developers, they do this because it's what the tools encourage: they encourage simplistic CRUD access and mistrust/suspicion/fear of SQL.
SQLAlchemy is quite different from this, because its primary focus is to model databases, not to provide some kind of declarative object language with its own set of semantics that do not exist in SQL.
Because Go can't do things like meta classes or creating/modifying types at runtime, a lot of this simply isn't there, even though people want it.
Sqlx does like 2 things; it adds named query parameter support, and it marshals rows into structs. Squirrel is just a query builder. The whole philosophy that the database must somehow be modeled and that access to the database is done via that model is absent.
[1] This is especially durable tarmac with which to pave your road to hell.
[2] http://github.com/jmoiron/johnny-cache
[3] This can mean "lots of requests", or "complex schema", or "complex reporting requirements"... all sorts of things.
On top of that, you got me another Gorilla Secure Cookie default integrity key to add to my project for attacking Gorilla SecureCookies.
No rate limiting, but it has pretty much everything else. If you want to add it I would welcome a pull request :)
There is a place for the GPL, but this is not it.
https://programmers.stackexchange.com/questions/132485/does-...
I understand why people don't like the GPL but its not a showstopper for most business applications.
Linking to a random programmers stackexchange question is an unwise way to make licensing decisions.
Per GNU's own faq at https://www.gnu.org/licenses/gpl-faq.html#UnreleasedMods:
A company is running a modified version of a GPL'ed program on a web site. Does the GPL say they must release their modified sources?
The GPL permits anyone to make a modified version and use it without ever distributing it to others. What this company is doing is a special case of that. Therefore, the company does not have to release the modified sources.
It is essential for people to have the freedom to make modifications and use them privately, without ever publishing those modifications. However, putting the program on a server machine for the public to talk to is hardly “private” use, so it would be legitimate to require release of the source code in that special case. Developers who wish to address this might want to use the GNU Affero GPL for programs designed for network server use.
In case you missed it: However, putting the program on a server machine for the public to talk to is hardly “private” use, so it would be legitimate to require release of the source code in that special case.There are numerous other potential consequences to the GPL and the question of when propagation occurs is ambiguous.
The GPL permits anyone to make a modified version and use it without ever distributing it to others. What this company is doing is a special case of that. Therefore, the company does not have to release the modified sources.
Specifically Therefore, the company does not have to release the modified sources.
The faq is explicitly stating that the GPL would not require releasing modified source, and that if you want to force the releasing of modified sources, you should use the AGPL, as it has a clause to cover network server softwareHow would you even know, or prove, in the first place that a company was running a modified version of the GPL'd source on their servers?
Anything more complicated that needs synchronization/database access, I'd rather just read and maintain application-level middleware. It's not rocket science.
go get github.com/go-bootstrap/go-bootstrap
$GOPATH/bin/go-bootstrap -dir github.com/$GIT_USER/$PROJECT_NAME
cd $GOPATH/src/github.com/$GIT_USER/$PROJECT_NAME && go run main.goAnyone with a 'large' web project written in Go want to chime in?
Perhaps you meant storing all session data is a bad idea versus just an ID? (If so, I'm with you)
If not - how would you identify an authenticated user? Or, how would you look up all their relevant session data in the DB?
A db based session, which really wouldn't be that hard to set up with github.com/gorilla/sessions, would just send a randomly generated session id to the client in a cookie, save the data in the db, then read that data back out of the db on the next request.
The way you've described things is how apps I'm familiar with do it (the latter way.) Thanks for clarifying.
You should authenticate it anyway, to prevent someone from trying to brute force ID generation (and therefore masquerading as another user). Otherwise all hope rides on you using a sufficiently long (CSPRNG-sourced) ID. Authenticating it is good practice.
> to prevent someone from trying to brute force ID generation
That's the point of using a large securely-random number.It's beautifully simple to give the client nothing more than a large random number to authenticate them.
I'm curious: what do you consider particularly flawed? DB backed sessions with simple ID-storing cookies suffer many of the same problems, with the primary issue being that you can MitM the cookie and masquerade as another user if not served over HTTPS.
DB (SQL, Redis, et. al) backed sessions are nice if you are storing genuine data (i.e. form data), because cookies typically have a 4KB per domain limit in most browsers.
If you are just storing a user ID, email address and/or admin flag, the cookie is authenticated (to prevent modification of those values) and served over HTTPS (only, ever) then there isn't an immediate problem there. You also don't have to worry about hitting your DB for each request - Redis is real quick, but (without hard numbers) I don't expect that sending 1KB of cookie header data would be slower either.
https://github.com/gorilla/securecookie/blob/master/secureco...
As for "impossible to revoke" well if you have control over your server you can do whatever you like so this falls into the very not-at-all-impossible category. As a baseline as long as there is no personal information in the "secure cookie" there really is no issue at all.
A expiry date system is literally impossible to revoke without somehow maintaining a list of valid or invalid cookies, and by that point, you are hitting a database for each cookie.
So, one way, you don't have as much control, and you can't revoke a stolen cookie with potentially high level access rights. The other way, you are replicating a db backed session, and heaping complexity on top of it.
impossible to revoke without somehow maintaining a list of valid or invalid cookies
Completely true. A minimum date like you are saying is still "some kind of list of valid or invalid cookies". Or are you going to get into the semantics of "that's not a list"? As an example of something that you can't do without tying a database into it, I've seen sites that let you log individual computers out of the system from your account page. No way to do that without a valid/not valid check in the DB.This site uses it http://gifuk.com/