File
File represents a file backed by a route, a reader or an opening function.
This API is used in Files.
Symbols
| Symbol | Class | Description |
|---|---|---|
| FileConfig | type | FileConfig defines a public type of API. |
| FileInfo | type | FileInfo defines a public type of API. |
| File | type | File defines a public type of API. |
| NewFile | func | Build NewFile. |
| NewFileWithContentType | func | Build NewFileWithContentType. |
| File.IsZero | func | Indicates the state of IsZero. |
| File.Info | func | Returns the metadata from the file. |
| File.Name | func | Give the name back. |
| File.Filename | func | Return the name of the file. |
| File.Len | func | Returns the declared size. |
| File.Size | func | Returns the declared size. |
| File.ContentType | func | Return the MIME type. |
| File.Type | func | Return the MIME type. |
| File.SetName | func | Sets SetName. |
| File.SetMIMEType | func | Sets SetMIMEType. |
| File.Open | func | It opens a new source of reading. |
| File.Read | func | Read the contents in the indicated buffer. |
| File.Write | func | Write content. |
| File.Seek | func | Change the reading or writing position. |
| File.Close | func | Close the open resources. |
| File.WriteTo | func | Copy the content to a io.Writer. |
| File.ReadFrom | func | Lee. ReadFrom. |
FileConfig
Declaration:
type FileConfig struct {
Path string
Name string
Type string
Content io.Reader
Open func() (io.ReadCloser, error)
Size int64
} FileConfig defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
Path | string | Route used. |
Name | string | Name of the value. |
Type | string | Declared type. |
Content | io.Reader | Associated content. |
Open | func() (io.ReadCloser, error) | Function that opens a new source. |
Size | int64 | Size in bytes. |
FileInfo
Declaration:
type FileInfo struct {
Name string
ContentType string
Size int64
} FileInfo defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
Name | string | Name of the value. |
ContentType | string | Half type declared. |
Size | int64 | Size in bytes. |
File
Declaration:
type File struct {
// contiene campos internos
} File defines a public type of API.
NewFile
Declaration:
func NewFile(config FileConfig) (File, error) Build NewFile.
Parameters
| Parameter | Type | Description |
|---|---|---|
config | FileConfig | Type value FileConfig required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | File | Type value File produced by the operation. |
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
The operation returns an error when it cannot complete the above contract.
Errors
NewFile returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
value, err := gox.NewFile(gox.FileConfig{}) NewFileWithContentType
Declaration:
func NewFileWithContentType(name string, contentType string, reader io.Reader) (File, error) Build NewFileWithContentType.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Name assigned. |
contentType | string | MIME type of content. |
reader | io.Reader | Reading source. |
Returns
| Return | Type | Description |
|---|---|---|
value | File | Type value File produced by the operation. |
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
The operation returns an error when it cannot complete the above contract.
Errors
NewFileWithContentType returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
value, err := gox.NewFileWithContentType("name", value, value) File.IsZero
Declaration:
func (file File) IsZero() bool Indicates the state of IsZero.
Returns
| Return | Type | Description |
|---|---|---|
value | bool | It indicates the result of the check. |
Behavior
It does not open or consume the content.
Usage syntax
value := file.IsZero() File.Info
Declaration:
func (file File) Info() FileInfo Returns the metadata from the file.
Returns
| Return | Type | Description |
|---|---|---|
value | FileInfo | Type value FileInfo produced by the operation. |
Usage syntax
value := file.Info() File.Name
Declaration:
func (file File) Name() string Give the name back.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := file.Name() File.Filename
Declaration:
func (file File) Filename() string Return the name of the file.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := file.Filename() File.Len
Declaration:
func (file File) Len() int64 Returns the declared size.
Returns
| Return | Type | Description |
|---|---|---|
value | int64 | Type value int64 produced by the operation. |
Usage syntax
value := file.Len() File.Size
Declaration:
func (file File) Size() int64 Returns the declared size.
Returns
| Return | Type | Description |
|---|---|---|
value | int64 | Type value int64 produced by the operation. |
Usage syntax
value := file.Size() File.ContentType
Declaration:
func (file File) ContentType() string Return the MIME type.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := file.ContentType() File.Type
Declaration:
func (file File) Type() string Return the MIME type.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := file.Type() File.SetName
Declaration:
func (file File) SetName(name string) error Sets SetName.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Name assigned. |
Returns
| Return | Type | Description |
|---|---|---|
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
The operation returns an error when it cannot complete the above contract.
Errors
SetName returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
err := file.SetName("name") File.SetMIMEType
Declaration:
func (file File) SetMIMEType(contentType string) error Sets SetMIMEType.
Parameters
| Parameter | Type | Description |
|---|---|---|
contentType | string | MIME type of content. |
Returns
| Return | Type | Description |
|---|---|---|
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
The operation returns an error when it cannot complete the above contract.
Errors
SetMIMEType returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
err := file.SetMIMEType(value) File.Open
Declaration:
func (file File) Open() (io.ReadCloser, error) It opens a new source of reading.
Returns
| Return | Type | Description |
|---|---|---|
value | io.ReadCloser | Type value io.ReadCloser produced by the operation. |
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
Each call requests a new source to the configured backend.
Errors
Open returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
value, err := file.Open() File.Read
Declaration:
func (file File) Read(p []byte) (int, error) Read the contents in the indicated buffer.
Parameters
| Parameter | Type | Description |
|---|---|---|
p | []byte | Type value []byte required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | int | Type value int produced by the operation. |
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
The operation returns an error when it cannot complete the above contract.
Errors
Read returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
value, err := file.Read(value) File.Write
Declaration:
func (file File) Write(p []byte) (int, error) Write content.
Parameters
| Parameter | Type | Description |
|---|---|---|
p | []byte | Type value []byte required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | int | Type value int produced by the operation. |
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
The operation returns an error when it cannot complete the above contract.
Errors
Write returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
value, err := file.Write(value) File.Seek
Declaration:
func (file File) Seek(offset int64, whence int) (int64, error) Change the reading or writing position.
Parameters
| Parameter | Type | Description |
|---|---|---|
offset | int64 | Type value int64 required by the operation. |
whence | int | Type value int required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | int64 | Type value int64 produced by the operation. |
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
The operation returns an error when it cannot complete the above contract.
Errors
Seek returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
value, err := file.Seek(value, value) File.Close
Declaration:
func (file File) Close() error Close the open resources.
Returns
| Return | Type | Description |
|---|---|---|
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
The subsequent calls depend on the state of the appeal.
Errors
Close returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
err := file.Close() File.WriteTo
Declaration:
func (file File) WriteTo(writer io.Writer) (int64, error) Copy the content to a io.Writer.
Parameters
| Parameter | Type | Description |
|---|---|---|
writer | io.Writer | A writing destination. |
Returns
| Return | Type | Description |
|---|---|---|
value | int64 | Type value int64 produced by the operation. |
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
The operation returns an error when it cannot complete the above contract.
Errors
WriteTo returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
value, err := file.WriteTo(value) File.ReadFrom
Declaration:
func (file File) ReadFrom(reader io.Reader) (int64, error) Lee. ReadFrom.
Parameters
| Parameter | Type | Description |
|---|---|---|
reader | io.Reader | Reading source. |
Returns
| Return | Type | Description |
|---|---|---|
value | int64 | Type value int64 produced by the operation. |
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
The operation returns an error when it cannot complete the above contract.
Errors
ReadFrom returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
value, err := file.ReadFrom(value)