bytest

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

source https://medium.com/@nicksoetaert/using-io-reader-to-simulate-an-arbitrary-sized-file-in-golang-4df6287cae51

Index

Constants

View Source
const (
	B = 1 << (10 * iota)
	KB
	MB
	GB // 1048576000 1073741824
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader simulates a fake read-only file of an arbitrary size. The contents of this file cycles through the lowercase alphabetical ascii characters (abcdefghijklmnopqrstuvwxyz) Data is generated as requested, so it is safe to generate a 100GB file with 1GB of memory free on your machine.

func NewReader

func NewReader(n int) *Reader

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

Read reads lowercase ascii characters into b from f. n is number of bytes read. If a Read is attempted at the end of the file, io.EOF is returned.

Jump to

Keyboard shortcuts

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