input

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package input replaces the old file_helper grab-bag with a small, error-honest set of helpers for the two things automation modules actually need from disk: reading a list file (proxies, emails, combos, names) and consuming it safely across worker goroutines.

The three layers, smallest to largest:

  • Lines / NonEmptyLines / Files — plain readers that return errors instead of swallowing them (the old file_helper printed the error and kept going with a nil scanner).
  • Queue[T] — a thread-safe consumer: Next() hands each item to exactly one worker, Random() samples with replacement.
  • Combo / ParseCombo — the "user:pass" convenience on top.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CSV

func CSV(path string) ([][]string, error)

CSV parses path as RFC-4180 CSV and returns every row. Ragged rows are allowed (FieldsPerRecord = -1) so partially-filled files still load, and leading whitespace is trimmed. Header handling, if any, is left to the module.

func Columns

func Columns(path, sep string) ([][]string, error)

Columns splits each non-empty line of path on sep into trimmed fields. It's the generic delimited-list loader: the kit does not decide what the columns mean — credentials, tokens, coordinates, proxy+label pairs — that is entirely the module's call.

rows, _ := input.Columns("list.txt", ":")
// rows[0] == []string{"a@b.com", "hunter2"}  // module decides the meaning

func Files

func Files(dir string) ([]string, error)

Files returns the base names of the regular files directly under dir (non-recursive, subdirectories skipped). A missing directory yields an empty slice and a nil error so callers can treat "no files yet" and "no dir yet" identically.

func Lines

func Lines(path string) ([]string, error)

Lines reads every line of the file at path (newline-stripped) and returns them in order. Unlike the old ReadFileLineArray it surfaces open/scan errors instead of printing and continuing.

func NonEmptyLines

func NonEmptyLines(path string) ([]string, error)

NonEmptyLines is Lines with blank / whitespace-only lines dropped and each surviving line trimmed. This is what most list files want.

Types

type Queue

type Queue[T any] struct {
	// contains filtered or unexported fields
}

Queue is a thread-safe consumer over a fixed slice of items. It is the canonical work source for a multi-threaded module: build one from a list file, then have every worker pull from it.

Two consumption styles:

  • Next() drains the queue in order, handing each item to exactly one worker (the "process every account once" pattern). When empty it returns ("", false) / (zero, false).
  • Random() samples with replacement and never empties (the "pick a random proxy / name" pattern).

A zero Queue is not usable; always construct via NewQueue or the Load* helpers. All methods are safe for concurrent use.

func LineQueue

func LineQueue(path string) (*Queue[string], error)

LineQueue loads the non-empty, trimmed lines of a file into a string Queue — the common case for name/email/token lists.

func NewQueue

func NewQueue[T any](items []T) *Queue[T]

NewQueue wraps items in a Queue. The slice is copied so later mutation of the caller's slice does not affect the queue.

func (*Queue[T]) Len

func (q *Queue[T]) Len() int

Len returns the total number of items the queue was built with.

func (*Queue[T]) Next

func (q *Queue[T]) Next() (T, bool)

Next returns the next unconsumed item and advances the cursor. The bool is false once every item has been handed out.

func (*Queue[T]) Random

func (q *Queue[T]) Random() (T, bool)

Random returns a uniformly random item (with replacement). The bool is false only when the queue is empty. Random ignores the Next cursor, so it keeps working after the queue has been fully drained by Next.

func (*Queue[T]) Remaining

func (q *Queue[T]) Remaining() int

Remaining returns how many items Next has not yet handed out.

func (*Queue[T]) Reset

func (q *Queue[T]) Reset()

Reset rewinds the Next cursor so the queue can be drained again.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL