Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefineFlags ¶
DefineFlags is a wrapper around CreateOpener for updating a default instance of Opener.
Types ¶
type FilenameTransform ¶
A FilenameTransform applies a transform to the filename before it used to open a file.
type NameWriteCloser ¶
type NameWriteCloser interface { // Name returns a name for the Writer. Name() string io.WriteCloser }
NameWriteCloser implements the io.WriteCloser interface, but also allows a a name to be returned so that the object can be identified.
type Opener ¶
type Opener struct { FilenameTransform FilenameTransform Perm os.FileMode // contains filtered or unexported fields }
var DefaultOpener *Opener
func CreateOpener ¶
CreateOpener creates an Opener and defines the sepecified flags fileFlag, forceFlag and appendFlag.
func (*Opener) Open ¶
func (o *Opener) Open(ctx context.Context) (NameWriteCloser, error)
Open opens and returns a file for output with the filename set by the fileFlag, applying any transform set in FilenameTransform.
If filename is empty/unset, os.Stdout will be used. If filename does not exist, it will be created with the mode set in o.Perm. If filename does exist, the behavior of this function will depend on the flags:
- if appendFlag is set on the command line the existing file will be appended to.
- if forceFlag is set on the command line the existing file will be truncated.
- if neither forceFlag nor appendFlag are set an error will be returned.