func (c *Control) Set(key, value string) {
	c.Values[key] = value
	for _, okey := range c.Order {
		if okey == key {
			return
		}
	}
	c.Order = append(c.Order, key)
	return
}
Set sets the value of a control variable.
package main
import (
	"fmt"
	"strings"
	"unicode"
)
type Control struct {
	Values map[string]string
	Order  []string
}
func NewControl() *Control {
	return &Control{
		Values: map[string]string{},
		Order:  []string{},
	}
}
func NewControlFromString(in string) (*Control, error) {
	c := Control{
		Values: map[string]string{},
		Order:  []string{},
	}
	var cur string
	lines := strings.Split(strings.Trim(strings.Replace(in, "\r\n", "\n", -1), "\n")+"\n", "\n")  
	for n, line := range lines {
		switch {
		case strings.HasPrefix(line, "#"):
			continue
		case strings.HasPrefix(line, " ") || strings.HasPrefix(line, "\t"):
			if cur == "" {
				return nil, fmt.Errorf("unexpected continuation line in control at line %d", n+1)
			}
			line = strings.TrimRightFunc(line[1:], unicode.IsSpace)
			if line == "." {
				line = ""  
			}
			if c.Values[cur] == "" {
				c.Values[cur] += line + "\n"
			} else {
				if !strings.HasSuffix(c.Values[cur], "\n") {
					c.Values[cur] += "\n"  
				}
				c.Values[cur] += line + "\n"
			}
		case strings.Contains(line, ":"):
			kv := strings.SplitN(line, ":", 2)
			cur = strings.TrimSpace(kv[0])
			val := strings.TrimSpace(kv[1])
			c.Order = append(c.Order, cur)
			c.Values[cur] = val
		case line == "":
			if n+1 != len(lines) {
				return nil, fmt.Errorf("expected end of control block at line %d", n+1)
			}
			break
		default:
			return nil, fmt.Errorf("expected key-value pair at line %d", n+1)
		}
	}
	return &c, nil
}
func (c *Control) String() string {
	if len(c.Values) != len(c.Order) {
		panic("control values length differs from order")
	}
	var b = new(strings.Builder)
	for _, key := range c.Order {
		val := c.Values[key]
		val = strings.Replace(val, "\n", "\n ", -1)        
		val = strings.Replace(val, "\n \n", "\n .\n", -1)  
		val = strings.TrimSuffix(val, "\n ")               
		fmt.Fprintf(b, "%s: %s\n", key, val)
	}
	return b.String()
}
func (c *Control) Get(key string) (string, bool) {
	val, ok := c.Values[key]
	return val, ok
}
func (c *Control) MustGet(key string) string {
	val, ok := c.Values[key]
	if !ok {
		panic("no such key " + key)
	}
	return val
}
func (c *Control) MightGet(key string) string {
	val, _ := c.Values[key]
	return val
}