stringio

package module
v0.0.0-...-605af32 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2014 License: BSD-3-Clause Imports: 2 Imported by: 0

README

stringio Build Status

Convenience functions to allow using strings as input to various "io" package interface functions.

See the documentation.

Documentation

Overview

Package stringio provides convenience functions for using strings with common io interfaces such as io.Reader and io.Writer, which normally use byte slices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Read

func Read(r io.Reader, n int) (int, string, error)

Read reads n bytes from the given io.Reader, and returns those bytes as a string. If the io.Reader provides fewer than n bytes, whatever bytes were returned (even if 0 bytes were returned) will be used to create the result string. The returned int and error values are taken directly from the return values of r.Read().

func ReadAt

func ReadAt(r io.ReaderAt, n int, off int64) (int, string, error)

ReadAt reads n bytes from the given io.ReaderAt, and returns those bytes as a string. If the io.ReaderAt provides fewer than n bytes, whatever bytes were provided (even if 0 bytes were provided) will be used to create the result string. The returned int and error values are taken directly from the return values of r.ReadAt()

func Write

func Write(w io.Writer, str string) (int, error)

Write converts str to a byte slice and passes it to w.Write(). The return values are passed unmodified from the call to w.Write().

Write is identical in behavior to io.WriteString, although it will usually be somewhat more performant since it avoids reallocating len(str) bytes if possible.

func WriteAt

func WriteAt(w io.WriterAt, str string, off int64) (int, error)

WriteAt converts str to a byte slice and passes it to w.WriteAt() along with off. The return values are passed unmodified from the call to w.WriteAt().

Types

This section is empty.

Jump to

Keyboard shortcuts

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