func SampleString(incoming string, max int) string {
	s := len(incoming)
	if s > max {
		s = max
	}
	return convertBadWhiteSpaceToBlanks(strings.TrimSpace(incoming[:s]))
}
SampleString converts a long multi-line string to a short one-line sample.
package util
import (
	"fmt"
	"github.com/golang/glog"
	"github.com/pkg/errors"
	"os/exec"
	"regexp"
	"strconv"
	"strings"
)
func GetProcesssGroupID(pid int) (int, error) {
	cmdOut, execErr := exec.Command(
		"/bin/ps", "--pid", strconv.Itoa(pid), "-o", "pgid", "--no-headers").Output()
	groupID := strings.TrimSpace(string(cmdOut))
	if execErr != nil || len(groupID) < 1 {
		return 0, errors.New(
			"Unable to yank groupID from ps command: " + groupID + " " + execErr.Error())
	}
	pgid, convErr := strconv.Atoi(groupID)
	if convErr != nil {
		return 0, convErr
	}
	return pgid, nil
}
func Check(msg string, err error) {
	if err != nil {
		glog.Fatal(errors.Wrap(err, msg))
	}
}
func killProcesssGroup(pgid int) {
	killer := exec.Command("/bin/kill", "-TERM", "--", fmt.Sprintf("-%v", pgid))
	killer.Start()
}
func convertBadWhiteSpaceToBlanks(s string) string {
	return strings.Map(func(r rune) rune {
		switch r {
		case 0x000A, 0x000B, 0x000C, 0x000D, 0x0085, 0x2028, 0x2029:
			return ' '
		default:
			return r
		}
	}, s)
}
var leading = regexp.MustCompile("^[0-9]+_")
func DropLeadingNumbers(s string) string {
	r := leading.FindStringIndex(s)
	if r == nil {
		return s
	}
	return s[r[1]:]
}