savo.la

2021-11-23

Go code snippets

A little copying is better than a little dependency.

This is a collection of code snippets which work better copied than imported. The list will hopefully evolve over time.

Helper for getting a pointer to a literal

func pointer[T any](x T) *T { return &x }

Shorthands for using package import.name/pan

import "import.name/pan"

func check(err error)                 { pan.Check(err) }
func checked[T any](x T, err error) T { pan.Check(err); return x }
Placed in the public domain by Timo Savola