ioutil

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompressByFileType added in v1.4.2

func CompressByFileType(file string, out io.WriteCloser) io.WriteCloser

func IsGzip

func IsGzip(path string) bool

IsGzip determines if a path points to a gzip compressed file. Returns true when the file has a .gz extension.

func OpenCompressed

func OpenCompressed(file string, flag int, perm os.FileMode) (io.WriteCloser, error)

OpenCompressed opens a file for writing and automatically compresses the content if the filename ends with .gz

func OpenDecompressed

func OpenDecompressed(path string) (io.ReadCloser, error)

OpenDecompressed opens a reader for the specified file and automatically gzip decompresses the content if the filename ends with .gz

func WriteCompressedBytes added in v1.7.4

func WriteCompressedBytes(file string, data []byte, flag int, perm os.FileMode) error

WriteCompressedBytes writes a byte slice to the specified file. If the filename ends with .gz, a byte slice is compressed and written.

func WriteCompressedJson

func WriteCompressedJson(file string, obj any) error

WriteCompressedJson writes the object to the specified file as a compressed json object if the filename ends with .gz.

Types

type Aborter added in v1.9.3

type Aborter func()

type AtomicWriter added in v1.7.6

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

func NewAtomicWriter added in v1.9.3

func NewAtomicWriter(path string, perm os.FileMode) (*AtomicWriter, error)

NewAtomicWriter creates a io.WriteCloser that performs an atomic write. The contents are initially written to a temporary file and only renamed into place when the writer is closed. NOTE: It's vital to check if an error is returned from Close() as it may indicate the file could not be renamed

func NewAtomicWriterCompressed added in v1.4.2

func NewAtomicWriterCompressed(path string, perm os.FileMode) (*AtomicWriter, error)

NewAtomicWriterCompressed creates a io.WriteCloser that performs an atomic write. The contents are initially written to a temporary file and only renamed into place when the writer is closed. NOTE: It's vital to check if an error is returned from Close() as it may indicate the file could not be renamed If path ends in .gz the contents written will be gzipped.

func (*AtomicWriter) Abort added in v1.7.6

func (a *AtomicWriter) Abort() error

Abort releases any open resources and cleans up temporary files without renaming them into place. Does nothing if the writer has already been closed.

func (*AtomicWriter) Close added in v1.7.6

func (a *AtomicWriter) Close() error

func (*AtomicWriter) Write added in v1.7.6

func (a *AtomicWriter) Write(p []byte) (n int, err error)

type OutputTarget added in v1.9.3

type OutputTarget func() (io.Writer, io.Closer, Aborter, error)

func NoOutputStream added in v1.9.3

func NoOutputStream() OutputTarget

func ToAtomicFile added in v1.9.3

func ToAtomicFile(path string, perm os.FileMode) OutputTarget

func ToStdOut added in v1.9.3

func ToStdOut() OutputTarget

func ToStdOutOrFileOrNoop added in v1.9.3

func ToStdOutOrFileOrNoop(outputPath string, perm os.FileMode) OutputTarget

type WrappedReadCloser added in v1.9.1

type WrappedReadCloser struct {
	io.ReadCloser
	// contains filtered or unexported fields
}

WrappedReadCloser is a struct that closes both the gzip.Reader and the underlying io.Closer.

func NewWrappedReadCloser added in v1.9.1

func NewWrappedReadCloser(r io.ReadCloser, c io.Closer) *WrappedReadCloser

NewWrappedReadCloser is a constructor function that initializes a WrappedReadCloser structure.

func (*WrappedReadCloser) Close added in v1.9.1

func (g *WrappedReadCloser) Close() error

Close closes both the gzip.Reader and the underlying reader.

type WrappedWriteCloser added in v1.9.1

type WrappedWriteCloser struct {
	io.WriteCloser
	// contains filtered or unexported fields
}

WrappedWriteCloser is a struct that closes both the gzip.Writer and the underlying io.Closer.

func NewWrappedWriteCloser added in v1.9.1

func NewWrappedWriteCloser(r io.WriteCloser, c io.Closer) *WrappedWriteCloser

NewWrappedWriteCloser is a constructor function that initializes a WrappedWriteCloser structure.

func (*WrappedWriteCloser) Close added in v1.9.1

func (g *WrappedWriteCloser) Close() error

Close closes both the gzip.Writer and the underlying writer.

Jump to

Keyboard shortcuts

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