path

package
v1.6.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Paths = New()

Paths is the Path singleton on which the top level functions from this package operate.

Functions

func InitPaths

func InitPaths(cfg *Path) error

InitPaths sets the default paths in the configuration based on CLI flags, configuration file and default values. It also tries to create the data path with mode 0750 and returns an error on failure.

func Resolve

func Resolve(fileType FileType, path string) string

Resolve resolves a path to a location in one of the default folders. For example, Resolve(Home, "test") returns an absolute path for "test" in the home path. In case path is already an absolute path, the path itself is returned.

Types

type FileType

type FileType string

FileType is an enumeration type representing the file types. Currently existing file types are: Home, Config, Data

const (
	// Home 家目录
	Home FileType = "home"
	// Config 配置文件目录
	Config FileType = "config"
	// Data 数据目录
	Data FileType = "data"
	// Logs 日志目录
	Logs FileType = "logs"
)

type Path

type Path struct {
	Home   string
	Config string
	Data   string
	Logs   string
}

Path 位置路径目录

func New

func New() *Path

New creates a new Paths object with all values set to empty values.

func (*Path) InitPaths

func (paths *Path) InitPaths(cfg *Path) error

InitPaths sets the default paths in the configuration based on CLI flags, configuration file and default values. It also tries to create the data path with mode 0750 and returns an error on failure.

func (*Path) Resolve

func (paths *Path) Resolve(fileType FileType, path string) string

Resolve resolves a path to a location in one of the default folders. For example, Resolve(Home, "test") returns an absolute path for "test" in the home path.

func (*Path) String

func (paths *Path) String() string

String returns a textual representation

Jump to

Keyboard shortcuts

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