A blog where Moazzam … rambles
-
Go – Finding and removing duplicate files on a Mac
My laptop’s hard drive is plagued with the same family pics stored in different folders. So, I wrote a simple app in Go to take care of this for me. The app does this by comparing MD5 hashes of files. Usage Assuming you saved the code in a file called main.go, here is how you…
-
3D Printing
The future is here – with 3D printing. If anyone has seen Star Trek, they will know about the synthesizer used in the show to make (synthesize) anything from coffee to costumes to anything else. This is how I felt when I first got my 3D printer and started making (printing) things with it. You…
-
Gogland build expired (renamed to Goland)
This confused me for a few minutes so I am writing this for those who have the same issue. Jetbrains renamed Gogland Goland. They also expired Gogland build. So you have to go to their site and download Goland and use that. Remove Gogland completely from your computer
-
Why Golang/Go is so awesome
I have been working with Go for quite some time now and know more about it. My initial thoughts about it were accurate, I think with some variations. Go really can do almost everything. It can be run like any interpreted language for development and compiled for production This is something I love about Go…
-
How are paints made for various painting mediums?
Paints are made by adding pigment (color) to something that will help it stick to the surface of a canvas (or anything else it can be painted on). Color Color, also referred to as pigment, is a powder with a specific color. For artist grade and premium grade paints this is ground up metal in…
-
Golang: Restart web server on file change
A great feature of scripting languages like PHP, Python and Ruby is that you don’t need to re-compile the app or restart a web server every time you change something. With Go, you need to restart the web server for your changes to take affect. This can be a pretty daunting task. We can, however,…
-
Golang: Get the function caller’s name
Problem Consider this code: package main import “fmt” func foo() { // foo() wants to know who called it fmt.Println(“HI”) } func main() { foo() } In the function foo, we want to get the name of the function (and preferably file name and number ) that called it. Solution We can get this information…
-
Golang: Connect to Postgres and selecting data from a table
You will need to get the Postgres driver first. In the terminal type: go get github.com/lib/pq Connecting to Postgres package main import ( _ “github.com/lib/pq” “database/sql” “fmt” ) func main() { // Connect to the DB, panic if failed db, err := sql.Open(“postgres”, “postgres://user:password@localhost/dbName?sslmode=disable”) if err != nil { fmt.Println(`Could not connect to db`) panic(err)…
-
Earn more by learning Go!
According to this article a friend forwarded to me, software developers who learn Go, Python or Scala (along with tech like Apache Spark) have found it easier to find jobs with better salaries. Learning Scala caused the highest boost and in the second place was Go. Learning python is a bit subjective in terms of…
-
Golang: Testing HTTP requests
Unit testing HTTP calls to external services is pretty easy in Go. Let’s say we have some code that makes HTTP requests like so: package something import ( “net/http” ) func SomeFunc(url) string { rs, _ := http.Get(url) defer rs.Body.Close() body, _ := ioutil.ReadAll(rs) return string(body) } We can test if the request is made…
Got any book recommendations?