io

package
v0.0.0-...-237f4c2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2020 License: GPL-3.0 Imports: 13 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLibraryExtension string = common.GetShareLibExt()
View Source
var DefaultPluginsFolder string = common.GetCurrentPath() + string(os.PathListSeparator) + "modules"

Functions

func CreateFileFolders

func CreateFileFolders(path string, perm os.FileMode) error

Delete a file or folder, within all sub items

func DeleteFile

func DeleteFile(path string) error

Delete a file or folder, within all sub items

func DeleteOrTruncateFile

func DeleteOrTruncateFile(path string) error

Delete a file (or truncate in case not suitable or delete folder, within all sub items

func ExistsFile

func ExistsFile(path string) bool

Check existance of a given file by name

func FindFilesIn

func FindFilesIn(path string, recursive bool, searchText string) []string

Finds files recursively or not, in a given path folder, with a file name prefix token

func FromJsonCode

func FromJsonCode(jsonCode string, itf interface{}) (interface{}, error)

Trasform Json code in Object

func FromJsonFile

func FromJsonFile(path string, itf interface{}) (interface{}, error)

Load a JSON file and transform it in Object

func FromXmlCode

func FromXmlCode(xmlCode string, itf interface{}) (interface{}, error)

Trasform Xml code in Object

func FromXmlFile

func FromXmlFile(path string, itf interface{}) (interface{}, error)

Load an Xml file and transform it in Object

func FromYamlCode

func FromYamlCode(yamlCode string, itf interface{}) (interface{}, error)

Trasform Yaml code in Object

func FromYamlFile

func FromYamlFile(path string, itf interface{}) (interface{}, error)

Load a Yaml file and transform it in Object

func GetCurrentFolder

func GetCurrentFolder() string

Retrieve current wotrking folder

func GetFiles

func GetFiles(path string, recursive bool) []string

Gets files in a folder (eventually recursively)

func GetMatchedFiles

func GetMatchedFiles(path string, recursive bool, matcher func(string) bool) []string

Gets files in a folder (eventually recursively), which name matches with given function execution

func GetPathSeparator

func GetPathSeparator() string

Gets the Path Separator as string type

func IsFolder

func IsFolder(path string) bool

Verifies if a atring file path corresponds to a directory

func Marshall

func Marshall(itf interface{}, format ParserFormat) ([]byte, error)

Marshall an object instance tranforming in byte array, reporting eventually errors based on the required parser format

func MarshallTo

func MarshallTo(itf interface{}, filePath string, format ParserFormat) error

Marshall an object instance tranforming in byte array and saving in a file in an existing path, reporting eventually errors based on the required parser format

func ToJson

func ToJson(itf interface{}) (string, error)

Transform an interface in JSON Code

func ToXml

func ToXml(itf interface{}) (string, error)

Transform an interface in XML Code

func ToYaml

func ToYaml(itf interface{}) (string, error)

Transform an interface in Yaml Code

func Unmashall

func Unmashall(code []byte, itf interface{}, format ParserFormat) (interface{}, error)

Marshall data byte arrays parsing the data into the interface returned of same type of the given one, reporting eventually errors based on the required parser format

func UnmashallFrom

func UnmashallFrom(filePath string, itf interface{}, format ParserFormat) (interface{}, error)

Marshall file byte arrays parsing the data into the interface returned of same type of the given one, reporting eventually errors based on the required parser format

Types

type FormatParser

type FormatParser interface {
	// Provided format
	ParserFormat() ParserFormat
	// Mashal an interface to the specified format in bytes
	Marshall(itf interface{}) ([]byte, error)
	// Mashal a byte array into the specified interface, returning the unmashalled element
	Unmashall(code []byte, itf interface{}) (interface{}, error)
}

Describes as a Plugin Parser executive must expose functions

func CollectAllPlugins

func CollectAllPlugins(pluginsFolder string, libExtension string) ([]FormatParser, error)

Looks up for plugin by a given ParserFormat, using eventually pluginsFolder and library exception excluded the dot, in case one of them is empty string it will be replaced with the package DefaultPluginsFolder and DefaultLibraryExtension variables

func LookupInPlugins

func LookupInPlugins(format ParserFormat, pluginsFolder string, libExtension string) (FormatParser, error)

Looks up for plugin by a given ParserFormat, using eventually pluginsFolder and library exception excluded the dot, in case one of them is empty string it will be replaced with the package DefaultPluginsFolder and DefaultLibraryExtension variables

type ParserFormat

type ParserFormat string
const (
	ParserFormatJson ParserFormat = "JSON"
	ParserFormatXml  ParserFormat = "XML"
	ParserFormatYaml ParserFormat = "YAML"
)

type ParserPlugin

type ParserPlugin func(format ParserFormat) (FormatParser, error)

Describe the exposed Plugin interface proxy function (expected function name = ParserPlugin

type PluginsCollector

type PluginsCollector func() ([]FormatParser, error)

Describe the exposed Plugin interface proxy function (expected function name = PluginsCollector

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL