|
You are here |
cep.dev | ||
| | | | |
blog.carlana.net
|
|
| | | | | A how-to for code generation in Go | |
| | | | |
www.integralist.co.uk
|
|
| | | | | 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
|
|
| | | | | 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
|
|
| | | Guide about working with JSON in go with HTTP server example | ||