func hash(salt string) Anonymisation {
	return func(s string) (string, error) {
		h := sha1.New()
		io.WriteString(h, s)
		io.WriteString(h, salt)
		return fmt.Sprintf("%x", h.Sum(nil)), nil
	}
}
Hashes (SHA1) the input.
package main
import (
	"crypto/sha1"
	"errors"
	"fmt"
	"io"
	"math/rand"
	"strconv"
	"strings"
	"time"
)
type Anonymisation func(string) (string, error)
type DateConfig struct {
	Format string
}
type RangeConfig struct {
	Gt     *float64
	Gte    *float64
	Lt     *float64
	Lte    *float64
	Output *string
}
type ActionConfig struct {
	Name        string
	Salt        *string
	DateConfig  DateConfig
	RangeConfig []RangeConfig
}
func anonymisations(configs *[]ActionConfig) ([]Anonymisation, error) {
	var err error
	res := make([]Anonymisation, len(*configs))
	for i, config := range *configs {
		if res[i], err = config.create(); err != nil {
			return nil, err
		}
	}
	return res, nil
}
func (ac *ActionConfig) saltOrRandom() string {
	if ac.Salt != nil {
		return *ac.Salt
	}
	return strconv.Itoa(rand.Int())
}
func (ac *ActionConfig) create() (Anonymisation, error) {
	switch ac.Name {
	case "nothing":
		return identity, nil
	case "outcode":
		return outcode, nil
	case "hash":
		return hash(ac.saltOrRandom()), nil
	case "year":
		return year(ac.DateConfig.Format)
	case "ranges":
		return ranges(ac.RangeConfig)
	}
	return nil, fmt.Errorf("can't create an action with name %s", ac.Name)
}
func identity(s string) (string, error) {
	return s, nil
}