Documentation ¶
Index ¶
- Variables
- type JSONFile
- func (f *JSONFile) Bytes() ([]byte, error)
- func (f *JSONFile) Close() error
- func (f *JSONFile) Field(key string, param interface{}) error
- func (f *JSONFile) Hash() (string, error)
- func (f *JSONFile) Reset() error
- func (f *JSONFile) String() (string, error)
- func (f *JSONFile) TarballPath() string
- func (f *JSONFile) URL() string
- func (f *JSONFile) Update(opts ...UpdateFileOption) error
- func (f *JSONFile) Write(p []byte) (int, error)
- type ReadWriteSeeker
- type UpdateFileOption
- func WithKeyValue(key string, value string) UpdateFileOption
- func WithKeyValueByte(key string, value []byte) UpdateFileOption
- func WithKeyValueInt(key string, value int64) UpdateFileOption
- func WithKeyValueTimestamp(key string, t int64) UpdateFileOption
- func WithKeyValueUint(key string, value uint64) UpdateFileOption
Constants ¶
This section is empty.
Variables ¶
var ( // ErrFieldNotFound parameter not found into json. ErrFieldNotFound = errors.New("JSON field not found") // ErrInvalidValueType invalid value type. ErrInvalidValueType = errors.New("invalid value type") // ErrInvalidURL invalid file URL. ErrInvalidURL = errors.New("invalid file URL") )
Functions ¶
This section is empty.
Types ¶
type JSONFile ¶
type JSONFile struct {
// contains filtered or unexported fields
}
JSONFile represents the JSON file and also implements the io.write interface, saving directly to the file.
func FromURL ¶
FromURL fetches the file from the given URL and returns its content. If tarballFileName is not empty, the URL is interpreted as a tarball file, tarballFileName is extracted from it and is returned instead of the URL content.
func (*JSONFile) Field ¶
Field returns the param by key and the position into byte slice from the file reader. Key can be a path to a nested parameters eg: app_state.staking.accounts.
func (*JSONFile) TarballPath ¶
TarballPath returns the tarball path.
func (*JSONFile) Update ¶
func (f *JSONFile) Update(opts ...UpdateFileOption) error
Update updates the file with the new parameters by key.
type ReadWriteSeeker ¶
type ReadWriteSeeker interface { io.ReadWriteSeeker Close() error Sync() error }
ReadWriteSeeker represents the owns ReadWriteSeeker interface inherit from io.ReadWriteSeeker.
type UpdateFileOption ¶
UpdateFileOption configures file update function with key and value.
func WithKeyValue ¶
func WithKeyValue(key string, value string) UpdateFileOption
WithKeyValue updates a file value object by key.
func WithKeyValueByte ¶ added in v0.26.0
func WithKeyValueByte(key string, value []byte) UpdateFileOption
WithKeyValueByte updates a file byte value object by key.
func WithKeyValueInt ¶
func WithKeyValueInt(key string, value int64) UpdateFileOption
WithKeyValueInt updates a file int value object by key.
func WithKeyValueTimestamp ¶
func WithKeyValueTimestamp(key string, t int64) UpdateFileOption
WithKeyValueTimestamp updates a time value.
func WithKeyValueUint ¶
func WithKeyValueUint(key string, value uint64) UpdateFileOption
WithKeyValueUint updates a file uint value object by key.