# gotb **Repository Path**: mirrors_karrick/gotb ## Basic Information - **Project Name**: gotb - **Description**: Go library that implements a few tail buffer abstract data types. - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-09 - **Last Updated**: 2026-03-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # gotb Implements a few tail buffer abstract data types. ## Description Tail buffers are useful when a program needs to track the N final elements added to a list, but not necessarily track previous elements. ```Go // tail copies the final num lines from io.Reader to io.Writer. func tail(num int, r io.Reader, w io.Writer) error { cb, err := gotb.NewStrings(num) if err != nil { return err } scanner := bufio.NewScanner(r) for scanner.Scan() { _, _ = cb.QueueDequeue(scanner.Text()) } if err := scanner.Err(); err != nil { return err } for _, line := range cb.Drain() { if _, err = fmt.Fprintln(w, line); err != nil { return err } } return nil } ```