by lkramer · 7y ago · 0 comments
The capitalisation is maybe the most annoying for me, I think it was designed with an IDE in mind (which would be able to automatic update all references), but I still find it a flawed design to have to touch potentially a lot of files, many places to change something from private to not private.
The problem with err has also bit me a few times. I don't like exceptions very much, but a solution like he suggests where a variable can only be ignore explicitly would solve it.
Go is not perfect, but for me there is nothing else better for microservices that I have come across.
If you don't have an IDE, you can start by making all functions and methods private. When you know you need it public, wrap the private function with the public one:
func myF(ana int) { /*do something */ }
func MyF(ana int) { myF(ana) }
The same trick is often used for adding extra parameters to a function, except that the function body must be moved: func myG(a int) { myG2(a, 7) }
func myG2(a, b int) { /*do something*/ }
Adding publicness to a function is like adding an extra parameter to it.Like Rust :)
Golint can enforce the "don't ignore errors" rule. I think it comes that way out of the box?