config_selector

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2020 License: MIT Imports: 5 Imported by: 0

README

config_selector

Configuration file selector for go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigFileSelector

type ConfigFileSelector struct {
	// contains filtered or unexported fields
}

func NewConfigFileSelector

func NewConfigFileSelector(fileName string, a ...LookupPlace) *ConfigFileSelector

Make new configuration loader for required filename using search places flags

func (*ConfigFileSelector) AddLookupPlace

func (s *ConfigFileSelector) AddLookupPlace(place LookupPlace)

Add lookup place

func (*ConfigFileSelector) IsFileExists

func (s *ConfigFileSelector) IsFileExists(path string) (bool, error)

Check if file specified by full path is exists

func (*ConfigFileSelector) LookupFilePathList

func (s *ConfigFileSelector) LookupFilePathList() (*[]string, error)

Get possible configuration file path list using lookup places in order set by lookup flags

func (*ConfigFileSelector) LookupFolderList

func (s *ConfigFileSelector) LookupFolderList() (*[]string, error)
Get well-known path list for searching config file's

Returns a list of well-known directories in order set by lookup flags

func (*ConfigFileSelector) SelectFirstKnownPlace

func (s *ConfigFileSelector) SelectFirstKnownPlace() (*string, error)

Get first existing configuration file path from places set by lookup flags

func (*ConfigFileSelector) SelectPath

func (s *ConfigFileSelector) SelectPath(path string) (*string, error)

Find configuration file in path or well known path list defined by lookup flags

func (*ConfigFileSelector) String

func (s *ConfigFileSelector) String() string

type LookupPlace

type LookupPlace string
const (
	HomeDir     LookupPlace = "Home"
	UserConfig  LookupPlace = ".config"
	CurrentPath LookupPlace = "./"
)

type SearchPlaces

type SearchPlaces []LookupPlace

Jump to

Keyboard shortcuts

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