location

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBaseDir = "."
	DefaultFolders = "config,../config"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Location

type Location interface {
	// AddFolder
	// adds a folder to the location manager. Config files will be searched
	// in this folder.
	//
	//   config.Location.Add("config")
	AddFolder(folders ...string) Location

	// Find
	// finds a config file in located folders.
	//
	//   config.Location.Find("app.json")
	//   config.Location.Find("app.yaml", "app.yml")
	Find(names ...string) (resource resource.Resource)

	// GetBaseDir
	// returns the base directory of the application.
	//
	//   return "./"
	//   return "/data/sketch"
	GetBaseDir() (dir string)

	// GetFolders
	// returns the list of folders.
	//
	//   return []string{
	//       "./config",
	//       "../config",
	//   }
	GetFolders() (list []string)

	// SetBaseDir
	// sets the base directory of the application.
	//
	//   config.Location.SetBaseDir("./")
	//   config.Location.SetBaseDir("/data/sketch")
	SetBaseDir(dir string) Location

	// SetFolders
	// sets the list of folders. Override the previous list.
	//
	//   config.Location.SetFolders([]string{
	//       "./config",
	//       "../config",
	//   })
	SetFolders(folders ...string) Location
}

Location is an interface for user operators.

func New

func New() Location

New creates a new location manager.

Jump to

Keyboard shortcuts

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