linkedlist.go
func (list *LinkedList) String() string {
	list.key.RLock()
	defer list.key.RUnlock()

	builder := bytes.NewBufferString("[")
	current := list.first
	for i := 0; i < 15 && current != nil; i++ {
		builder.WriteString(fmt.Sprintf("%v ", current.payload))
		current = current.next
	}
	if current == nil || current.next == nil {
		builder.Truncate(builder.Len() - 1)
	} else {
		builder.WriteString("...")
	}
	builder.WriteRune(']')
	return builder.String()
}
func (list *LinkedList) String() string {
	list.key.RLock()
	defer list.key.RUnlock()

	builder := bytes.NewBufferString("[")
	current := list.first
	for i := 0; i < 15 && current != nil; i++ {
		builder.WriteString(fmt.Sprintf("%v ", current.payload))
		current = current.next
	}
	if current == nil || current.next == nil {
		builder.Truncate(builder.Len() - 1)
	} else {
		builder.WriteString("...")
	}
	builder.WriteRune(']')
	return builder.String()
}
func ( list * LinkedList ) String ( ) string { list . key . RLock ( ) defer list . key . RUnlock ( ) builder := bytes . NewBufferString ( " " ) current := list . first for i := 0 ; i < 15 && current != nil ; i ++ { builder . WriteString ( fmt . Sprintf ( " " , current . payload ) ) current = current . next } if current == nil || current . next == nil { builder . Truncate ( builder . Len ( ) - 1 ) } else { builder . WriteString ( " " ) } builder . WriteRune ( ']' ) return builder . String ( ) }
// String prints upto the first fifteen elements of the list in string format.
String prints upto the first fifteen elements of the list in string format .