Documentation
¶
Overview ¶
package atomicwrite implements an atomic io.WriteCloser instance backed by the gocloud.dev/blob package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New returns a new AtomicWriter instance. 'uri' is expected to a valid gocloud.dev/blob URI however if 'uri' is passed in as a schema-less Unix-style path it will be converted to a gocloud.dev/blob `file://` URI. Under the hood this method will attempt to create a new temporary file for the "path" element of URI whose filename will be appended with a random string. This temporary file is where data will be written to until the `Close` method is invoked at which point the data in the temporary file will be copied to the final path (defined by 'uri') and the temporary file will be removed. This method will create a new `blob.Writer` instance (which implements `io.WriteCloser`) with the default nil `blob.WriterOptions`. If you need to specify custom writer options you should use the `NewWithOptions` method.
func NewWithOptions ¶
func NewWithOptions(ctx context.Context, uri string, writer_opts *blob.WriterOptions) (io.WriteCloser, error)
NewWithOptions returns a new AtomicWriter instance, specifying 'writer_opts' as the custom options used to create the underlying `blob.Writer` instance.
Types ¶
type AtomicWriter ¶
type AtomicWriter struct { io.WriteCloser // contains filtered or unexported fields }
type AtomicWriter implements an atomic io.WriteCloser instance backed by the gocloud.dev/blob package.
func (*AtomicWriter) Close ¶
func (aw *AtomicWriter) Close() error
Close will copy data written to the intermediate temporary file to the final path defined in the `New` constructor. Upon successfully completing this operation the temporary file will be removed.