-
Go: What is rune?
One of the new concepts developers encounter when working with strings in Go is the rune. As shown in the code below, s[0] is a byte, and its ASCII code is 72. However, the code below results in a compilation error, stating that ch is of type rune, not byte. If you examine Go’s internal…
-
Go: cannot assign to struct field in map
One of the surprising things beginners realize about Go is that maps are passed by reference. This means if a map is modified in the function it was passed to, the caller will also see the changes. However, if m is a map[int]node, m[0] is not a reference to a node but the value stored…
-
Go Docs are good, but not enough!
I believe programming language standard library documentation should mention the time and space complexity of every operation. Currently, Go docs only explain how to use data structures, but nothing more. This is unacceptable. I need to know how much time it takes to initialize an array of size n without reading the source code. One…
-
Can’t agree with this MORE!
I wanted to see how hard it was to implement this sort of thing in Go, with as nice an API as I could manage. It wasn’t hard.Having written it a couple of years ago, I haven’t had occasion to use it once. Instead, I just use “for” loops.You shouldn’t use it either. Rob Pike
-
Mastering the Art of Reading Go code
* I could not come up with any good name for this post, so here it is. It is a case study for reading go code. I have worked with Java/Python for more than 9 years now. Most of my production code was in Java. When I want to write a code to parse some…
-
Read the code
“The problem is, if you’re not a hacker, you can’t tell who the good hackers are.” Paul Graham To understand Docker, go read about cgroups.To comprehend Bitcoin, go delve into its white paper.To learn MapReduce, go study the original authors’ work….To know what a code does, go read its source code.You’re not going to get…
-
Resist the urge for writing unit tests, unless you have a good reason to do so.
TLDR: Don’t write unit tests for things that will cause your program not to compile if they go wrong. WARN: This is a highly opinionated article. There is a prevailing trend nowadays to create unit tests for every method. Advocates of unit tests assert that by having these tests, you can refactor code without fearing…
-
Dependency Injection
Spring has made dependency injection a fancy thing. It has too much complexity in the procedure of creating beans. But dependency injection itself is just a simple idea; dependency injection is injecting dependencies! Nothing more. It means if piece of code A is depended on code B then code B should be passed into A,…