// TruncateKey is used to remove the prefix of the key
425534
func (s *StorageView) TruncateKey(full string) string {
	return strings.TrimPrefix(full, s.prefix)
}
484686
func truncateString(str string, num int) string {
	text := str
	if len(str) > num {
		if num > 3 {
			num -= 3
		}
		text = str[0:num] + "..."
	}
	return text
}
1360549
func truncateWithEllipsis(str string, maxWidth int, leftTruncate bool) string {
	if len(str) <= maxWidth {
		return str
	}
	if leftTruncate {
		return fmt.Sprintf("...%s", str[len(str)-(maxWidth-3):])
	}
	return fmt.Sprintf("%s...", str[:maxWidth-3])
}
865928
func (r *Redshift) Truncate(tx *sql.Tx, schema, table string) error {
	// We run 'DELETE FROM' instead of 'TRUNCATE' because 'TRUNCATE' can't be run in a transaction.
	// See http://docs.aws.amazon.com/redshift/latest/dg/r_TRUNCATE.html.
	truncStmt, err := tx.PrepareContext(r.ctx, fmt.Sprintf(`DELETE FROM "%s"."%s"`, schema, table))
	if err != nil {
		return err
	}
	_, err = truncStmt.ExecContext(r.ctx)
	return err
}
1202451
func (c *Certificate) GetTruncatedCertificateName() string {
	certName := c.CertFile.String()

	// Truncate certificate information only if it's a well formed certificate content with more than 50 characters
	if !c.CertFile.IsPath() && strings.HasPrefix(certName, certificateHeader) && len(certName) > len(certificateHeader)+50 {
		certName = strings.TrimPrefix(c.CertFile.String(), certificateHeader)[:50]
	}

	return certName
}
1070129
func (stack *Stack) TruncateToSize(newsize int) {
	el := make([]StackElem, newsize)
	copy(el, stack.elements)
	stack.elements = el
	stack.tos = newsize - 1
}
200123
func (b *BaseBuilder) TruncateTable(table string) *Query {
	sql := "TRUNCATE TABLE " + b.db.QuoteTableName(table)
	return b.NewQuery(sql)
}
565028
func Truncate(s string, w int, tail string) string {
	return DefaultCondition.Truncate(s, w, tail)
}
733444
func (l *Log) truncate(index uint64, term uint64) error {
	l.mutex.Lock()
	defer l.mutex.Unlock()
	debugln("log.truncate: ", index)

	// Do not allow committed entries to be truncated.
	if index < l.commitIndex {
		debugln("log.truncate.before")
		return fmt.Errorf("raft.Log: Index is already committed (%v): (IDX=%v, TERM=%v)", l.commitIndex, index, term)
	}

	// Do not truncate past end of entries.
	if index > l.startIndex+uint64(len(l.entries)) {
		debugln("log.truncate.after")
		return fmt.Errorf("raft.Log: Entry index does not exist (MAX=%v): (IDX=%v, TERM=%v)", len(l.entries), index, term)
	}

	// If we're truncating everything then just clear the entries.
	if index == l.startIndex {
		debugln("log.truncate.clear")
		l.file.Truncate(0)
		l.file.Seek(0, os.SEEK_SET)

		// notify clients if this node is the previous leader
		for _, entry := range l.entries {
			if entry.event != nil {
				entry.event.c <- errors.New("command failed to be committed due to node failure")
			}
		}

		l.entries = []*LogEntry{}
	} else {
		// Do not truncate if the entry at index does not have the matching term.
		entry := l.entries[index-l.startIndex-1]
		if len(l.entries) > 0 && entry.Term() != term {
			debugln("log.truncate.termMismatch")
			return fmt.Errorf("raft.Log: Entry at index does not have matching term (%v): (IDX=%v, TERM=%v)", entry.Term(), index, term)
		}

		// Otherwise truncate up to the desired entry.
		if index < l.startIndex+uint64(len(l.entries)) {
			debugln("log.truncate.finish")
			position := l.entries[index-l.startIndex].Position
			l.file.Truncate(position)
			l.file.Seek(position, os.SEEK_SET)

			// notify clients if this node is the previous leader
			for i := index - l.startIndex; i < uint64(len(l.entries)); i++ {
				entry := l.entries[i]
				if entry.event != nil {
					entry.event.c <- errors.New("command failed to be committed due to node failure")
				}
			}

			l.entries = l.entries[0 : index-l.startIndex]
		}
	}

	return nil
}
422902
func (e *Env) normalizeKey(k string) string {
	if e.CaseInsensitive {
		return strings.ToUpper(k)
	}
	return k
}
1266415
func truncate(rev string) string {
	rev = strings.TrimSpace(rev)
	if len(rev) > 12 {
		return rev[:12]
	}
	return rev
}
687311
func (s *DescribeCustomKeyStoresOutput) SetTruncated(v bool) *DescribeCustomKeyStoresOutput {
	s.Truncated = &v
	return s
}
979808
func (b *Buffer) Truncate(n int) {
	if n == 0 {
		b.off = 0
		b.buf = b.buf[0:0]
	} else {
		b.buf = b.buf[0 : b.off+n]
	}
}
596583
func (k *Keyring) RemoveKey(term uint32) (*Keyring, error) {
	// Ensure this is not the active key
	if term == k.activeTerm {
		return nil, fmt.Errorf("cannot remove active key")
	}

	// Check if this term does not exist
	if _, ok := k.keys[term]; !ok {
		return k, nil
	}

	// Delete the key
	clone := k.Clone()
	delete(clone.keys, term)
	return clone, nil
}
238245
func TruncSeek(fd *os.File) {
	if fd != nil {
		fd.Truncate(0)
		fd.Seek(0, os.SEEK_SET)
	}
}
1108123
func (b MemFile) Truncate(size int64) (err error) {
	b.mutex.Lock()
	err = b.Buffer.Truncate(size)
	b.mutex.Unlock()
	return
}
966113
func extractKey(s, prefix string) (string, error) {
	substrings := strings.SplitN(s, "/", 2)
	if len(substrings) <= 1 || substrings[0] != prefix {
		switch prefix {
		case deleteFromPrimitiveListDirectivePrefix:
			return "", mergepatch.ErrBadPatchFormatForPrimitiveList
		case setElementOrderDirectivePrefix:
			return "", mergepatch.ErrBadPatchFormatForSetElementOrderList
		default:
			return "", fmt.Errorf("fail to find unknown prefix %q in %s\n", prefix, s)
		}
	}
	return substrings[1], nil
}