Style guide: Document avoidance of globals in Go code (#29803)

* Chore: Document avoidance of globals in Go code

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
pull/29964/head
Arve Knudsen 5 years ago committed by GitHub
parent cedaf41a36
commit 12123f0540
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      contribute/style-guides/backend.md

@ -39,3 +39,9 @@ Tests must use the standard library, `testing`. For assertions, prefer using [te
The majority of our tests uses [GoConvey](http://goconvey.co/) but that's something we want to avoid going forward.
In the `sqlstore` package we do database operations in tests and while some might say that's not suited for unit tests. We think they are fast enough and provide a lot of value.
## Globals
As a general rule of thumb, avoid using global variables, since they make the code difficult to maintain and reason
about, and to write tests for. The Grafana codebase currently does use a lot of global variables, especially when
it comes to configuration, but that is a problem we're trying to solve.

Loading…
Cancel
Save