Hi there 👋

Welcome to my blog

Understanding HTML templates in Go (golang)

I use Echo in this post, but you could also use plain net/http, or any of the other awesome web frameworks for Go, see a list here. The Go standard library provides a html/template package, for dynamically rendering HTML, it is built on top of text/template Go templates are normal HTML files, with “Actions” (data evaluations or control structures), these “Actions” are delimited via {{and}}. A template is executed via applying a data structure to it, the data structure is referenced as a dot ....

December 30, 2020 · 4 min · lu4p

Inner workings of allocating slices with Go (golang)

I wasn’t sure what the performance impact of preallocating a slice with make vs. just letting the slice grow via append is, so I investigated a little. Arrays In order to understand what a slice is one needs to first understand how arrays work in go. An array’s type definition specifies a length and an element type. For example, the type [3]int represents an array of three integers. An array’s size is fixed, its length is part of the type, so [2]int and [3]int are incompatible, e....

December 2, 2020 · 6 min · lu4p