My First Golang
The strength of Golang is in its parallel processing capabilities. To replace crawlers or stress with Golang, let's write a http request code using parallel processing. First things first, let's start with Hello World!
I first started with some initial setups for Go environment and essential build settings as a Sublime user. Having notations such as ': =' and using modern abbreviations, also using methods similar to C for faster speeds. Below is a wiki page as reference.
Easy!... actually, I didn't realize I was writing Printf instead of printf and I actually got stuck for a bit. I'm already learning about the notation rules for Golang. Below is from the documentation Effective Go
"Names are as important in Go as in any other language. They even have semantic effect: the visibility of a name outside a package is determined by whether its first character is upper case. It's therefore worth spending a little time talking about naming conventions in Go programs."
I Want To Execute a Http Request
From my experience, the learning process becomes a lot more fun and time efficient when you practice writing code as a web application. When looking at an Go example http package I found the line defer resp.Body.Close() after acquiring a response. Explicitly executing the end of an response is not hard to wrap my head around but defer is something that is not familiar with me and seems to be a notation specific to Golang. Let's take a closer look.
Even after the processing terminated due to an error, the defer lines still executed. The lines that did not execute are the lines after panic.
This is it for the introduction. We'll be playing around with some print in the next installment!