ioutil

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2022 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadConfigFile added in v0.0.4

func ReadConfigFile(filepath string, optFns ...func(*ConfigFileOptions) error) (interface{}, error)

Read the file given by filepath. Viper instance is returned if optClass is not provided. Otherwise Unmarshalling will be performed. If optClass is provided, Unmarshalling will be performed and the class will be updated. No object will be returned. optClass is expected to be a pointer to a struct.

For example:

	type Config struct {
		Name string
	}
	var config Config
	err := ReadConfigFile("config.yaml", WithClass(&config))
	if err != nil {
     doSomethingWithError(err)
	}

func ReadIniFile

func ReadIniFile(filepath string) (*ini.File, error)

Read the file given by filepath as an INI file

func ReadYamlFile

func ReadYamlFile(filepath string, optFns ...func(*ConfigFileOptions) error) (interface{}, error)

Read the file given by filepath as a YAML file

Types

type ConfigFileOptions added in v0.0.4

type ConfigFileOptions struct {
	Type  string
	Class interface{}
}

Supported options for reading config files

type ConfigFileOptionsFunc added in v0.0.4

type ConfigFileOptionsFunc func(f *ConfigFileOptions) error

ConfigFileOptionsFunc is a type alias for ConfigFileOptions functional option

func WithCFOClass added in v0.0.4

func WithCFOClass(class interface{}) ConfigFileOptionsFunc

WithCFOClass is a helper function to construct functional options that sets class for unmarshalling on config's ConfigFileOptions.

func WithCFOType added in v0.0.4

func WithCFOType(fileType string) ConfigFileOptionsFunc

WithCFOType is a helper function to construct functional options that sets config file type on config's ConfigFileOptions.

Jump to

Keyboard shortcuts

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