Documentation ¶
Overview ¶
Package io contains helper functions related to io This file contains all the utilities available to be used from copying files to reading JSON
Index ¶
- Constants
- Variables
- func GetOS() string
- type AssetHandler
- func (assetHandler AssetHandler) CopyFile(source string, destination string, override bool) error
- func (assetHandler AssetHandler) CopyMultipleFiles(sources []string, destinations []string, overrides []bool) error
- func (assetHandler AssetHandler) GetRoot() (string, error)
- func (assetHandler AssetHandler) ParseJson(fileName string, out interface{}) (err error)
- func (assetHandler AssetHandler) ParseYml(fileName string, out interface{}) error
- func (assetHandler AssetHandler) ReadFile(fileName string) ([]byte, error)
- func (assetHandler AssetHandler) WriteFile(fileName string, data []byte) error
- func (assetHandler AssetHandler) WriteJson(fileName string, in interface{}) error
- func (assetHandler AssetHandler) WriteYml(fileName string, in interface{}) error
- type IOHandler
- type NormalHandler
- func (normalHandler NormalHandler) CopyFile(source string, destination string, override bool) error
- func (normalHandler NormalHandler) CopyMultipleFiles(sources []string, destinations []string, overrides []bool) error
- func (normalHandler NormalHandler) GetRoot() (string, error)
- func (normalHandler NormalHandler) ParseJson(fileName string, out interface{}) (err error)
- func (normalHandler NormalHandler) ParseYml(fileName string, out interface{}) error
- func (normalHandler NormalHandler) ReadFile(fileName string) ([]byte, error)
- func (normalHandler NormalHandler) WriteFile(fileName string, data []byte) error
- func (normalHandler NormalHandler) WriteJson(fileName string, in interface{}) error
- func (normalHandler NormalHandler) WriteYml(fileName string, in interface{}) error
Constants ¶
const ( WINDOWS = "windows" DARWIN = "darwin" LINUX = "linux" )
Variables ¶
var Sep = string(filepath.Separator) // separator based on the OS
Functions ¶
Types ¶
type AssetHandler ¶
type AssetHandler byte
var AssetIO AssetHandler = 1
func (AssetHandler) CopyFile ¶
func (assetHandler AssetHandler) CopyFile(source string, destination string, override bool) error
Copies file from src to destination and if destination file exists, it overrides the file content based on if override is specified. Copies file from binary assets
func (AssetHandler) CopyMultipleFiles ¶
func (assetHandler AssetHandler) CopyMultipleFiles(sources []string, destinations []string, overrides []bool) error
Copies multiple files from source to destination. Source files are from binary assets
func (AssetHandler) GetRoot ¶
func (assetHandler AssetHandler) GetRoot() (string, error)
Returns the root path to the asset files in terms of assets folder
func (AssetHandler) ParseJson ¶
func (assetHandler AssetHandler) ParseJson(fileName string, out interface{}) (err error)
Parses JSON from the data in assets
func (AssetHandler) ParseYml ¶
func (assetHandler AssetHandler) ParseYml(fileName string, out interface{}) error
Parses YML from the data in assets
func (AssetHandler) ReadFile ¶
func (assetHandler AssetHandler) ReadFile(fileName string) ([]byte, error)
Reads the file and provides it's content as a string. From binary assets
func (AssetHandler) WriteFile ¶
func (assetHandler AssetHandler) WriteFile(fileName string, data []byte) error
Writes text to binary assets (invalid to do)
func (AssetHandler) WriteJson ¶
func (assetHandler AssetHandler) WriteJson(fileName string, in interface{}) error
Writes JSON data to a binary asset (not valid)
func (AssetHandler) WriteYml ¶
func (assetHandler AssetHandler) WriteYml(fileName string, in interface{}) error
Writes YML data to a binary asset (not valid)
type IOHandler ¶
type IOHandler interface { GetRoot() (string, error) CopyFile(string, string, bool) error CopyMultipleFiles([]string, []string, []bool) error ReadFile(string) ([]byte, error) WriteFile(string, []byte) error ParseJson(string, interface{}) error ParseYml(string, interface{}) error WriteJson(string, interface{}) error WriteYml(string, interface{}) error }
type NormalHandler ¶
type NormalHandler byte
var NormalIO NormalHandler = 0
func (NormalHandler) CopyFile ¶
func (normalHandler NormalHandler) CopyFile(source string, destination string, override bool) error
Copies file from src to destination and if destination file exists, it overrides the file content based on if override is specified. Copies file from OS filesystem
func (NormalHandler) CopyMultipleFiles ¶
func (normalHandler NormalHandler) CopyMultipleFiles(sources []string, destinations []string, overrides []bool) error
Copies multiple files from source to destination. Source files are from filesystem
func (NormalHandler) GetRoot ¶
func (normalHandler NormalHandler) GetRoot() (string, error)
Returns the root path to the files in terms of this executable
func (NormalHandler) ParseJson ¶
func (normalHandler NormalHandler) ParseJson(fileName string, out interface{}) (err error)
Parses JSON from the file on filesystem
func (NormalHandler) ParseYml ¶
func (normalHandler NormalHandler) ParseYml(fileName string, out interface{}) error
Parses YML from the file on filesystem
func (NormalHandler) ReadFile ¶
func (normalHandler NormalHandler) ReadFile(fileName string) ([]byte, error)
Reads the file and provides it's content as a string. From normal filesystem
func (NormalHandler) WriteFile ¶
func (normalHandler NormalHandler) WriteFile(fileName string, data []byte) error
Writes text to a file on normal filesystem
func (NormalHandler) WriteJson ¶
func (normalHandler NormalHandler) WriteJson(fileName string, in interface{}) error
Writes JSON data to a file on filesystem
func (NormalHandler) WriteYml ¶
func (normalHandler NormalHandler) WriteYml(fileName string, in interface{}) error
Writes YML data to a file on filesystem