Month: December 2016

  • Golang: Make HTTP requests

    A simple GET request can be made like this: package main import ( “net/http” “ioutil” ) func main() { // Make a get request rs, err := http.Get(“https://google.com”) // Process response if err != nil { panic(err) // More idiomatic way would be to print the error and die unless it’s a serious error }…

  • Golang: Polymorphism

    Polymorphism is a bit different in Go. It supports polymorphism only through interfaces (and not through inheritance). To help you understand better, here is an example: import “fmt” type Car interface { func Drive() } type Lamborgini struct { // Implement the Car interface func Drive() { fmt.Println(“Driving”) } } func driveACar(car Car) { car.Drive()…