Let's code

Starting a New Ambitious Project

For a very short time, I used the Spacemacs emacs distribution. It’s very nice, but I ended up backing to vim and eventually, I moved to VS Code. Code editors away, when I was using Spacemacs, I found the Magit git client. Magit is an interface to the version control system Git, implemented as an Emacs package. Magit aspires to be a complete Git porcelain. While we cannot (yet) claim that Magit wraps and improves upon each and every Git command, it is complete enough to allow even experienced Git users to perform almost all of their daily version control tasks directly from within Emacs.

json: unmarshal custom date formats

When we are building a JSON API, many times we have to deal with dates that we can’t have control of the layout. Let’s see a common example using a format that Go knows by default. type Checkin struct { Timestamp time.Time `json:"timestamp"` User string `json:"user"` } func main() { j := `{"timestamp":"2016-11-02T08:18:20Z", "user":"John Doe"}` var c Checkin // error handling omitted for simplicity (don't do this). json.Unmarshal([]byte(j), &c) fmt.Println(c) } Run on Playground.

Variadic functions in Go

Let’s create a function that we can pass 3 numbers as arguments and them it returns the average of this numbers. func average(num1, num2, num3 float64) float64 { avg := (num1 + num2 + num3) / 3 return avg } and then, you call it like this func main() { fmt.Println(average(2, 4, 6)) } Le’ts run to see if works $ go run average.go 4 It works. Super easy, but not so useful.