code: func UTF8StringFromBytes(bs []byte) (string, error) {
  	// Provide fast path for good strings
  	if utf8.Valid(bs) {
  		return string(bs), nil
  	}
  	buf := new(bytes.Buffer)
  	var runeErrs []string
  	// This loops over runs (code points and unlike range of string gives us index of code point (i.e. utf8 char)
  	// not bytes, which we want for error message
  	var offset int
  	// Iterate over character indices (not byte indices)
  	for i := 0; i < len(bs); i++ {
  		r, n := utf8.DecodeRune(bs[offset:])
  		buf.WriteRune(r)
  		if r == utf8.RuneError {
  			runeErrs = append(runeErrs, fmt.Sprintf("0x% X (at index %d)", bs[offset:offset+n], i))
  		}
  		offset += n
  	}
  	str := buf.String()
  	errHeader := fmt.Sprintf("bytes purported to represent the string '%s'", str)
  	switch len(runeErrs) {
  	case 0:
  		// should not happen
  		return str, fmt.Errorf("bytes appear to be invalid utf8 but do not contain invalid code points")
  	case 1:
  		return str, fmt.Errorf("%s contain invalid utf8 byte sequence: %s", errHeader, runeErrs[0])
  	default:
  		return str, fmt.Errorf("%s contain invalid utf8 byte sequences: %s", errHeader,
  			strings.Join(runeErrs, ", "))
  	}
  }
docs: // Checks whether the bytes passed are valid utf8 string bytes. If they are not returns a sanitised string version of the
  // bytes with offending sequences replaced by the utf8 replacement/error rune and an error indicating the offending
  // byte sequences and their position. Note: always returns a valid string regardless of error.