Explore >> Select a destination


You are here

cep.dev
| | blog.carlana.net
4.9 parsecs away

Travel
| | A how-to for code generation in Go
| | www.integralist.co.uk
4.0 parsecs away

Travel
| | The following code doesn't do what you might expect: package main import "fmt" func main() { var i *impl fmt.Println("i == nil:", i == nil) what(i) } type impl struct{} func (i *impl) do() {} func what(i interface{ do() }) { fmt.Println("i == nil:", i == nil) } If you expected the what function to print i == nil: true, then keep reading... Typed Nils The behavior observed is due to the way interfaces and nil values interact in Go.
| | hjr265.me
4.3 parsecs away

Travel
| | Working with user-generated content is always a nightmare interesting. Let's say you are building a blogging platform with Go. Your users write posts in Markdown that the platform then renders as HTML. And, you want to add target="_blank" and rel="noreferrer noopener" to all the external links. How do you do that? Annotated Code The steps are simple: Parse the HTML with golang.org/x/net/html. Walk the tree. The annotated code below implements a simple Walk function.
| | xnacly.me
29.6 parsecs away

Travel
| Guide about working with JSON in go with HTTP server example