pathx

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NL = "\n"
)

NL defines a new line.

Variables

This section is empty.

Functions

func Clean

func Clean(category string) error

Clean deletes all templates and removes the parent directory.

func Copy

func Copy(src, dest string) error

func CreateIfNotExist

func CreateIfNotExist(file string) (*os.File, error)

CreateIfNotExist creates a file if it is not exists.

func CreateTemplate

func CreateTemplate(category, name, content string) error

CreateTemplate writes template into file even it is exists.

func FileExists

func FileExists(file string) bool

FileExists returns true if the specified file is exists.

func FileNameWithoutExt

func FileNameWithoutExt(file string) string

FileNameWithoutExt returns a file name without suffix.

func FindGoModPath

func FindGoModPath(dir string) (string, bool)

FindGoModPath returns the path in project where has file go.mod, it maybe return empty string if there is no go.mod file in project

func FindProjectPath

func FindProjectPath(loc string) (string, bool)

FindProjectPath returns the parent directory where has file go.mod in project

func GetAutoCompleteHome

func GetAutoCompleteHome() (string, error)

GetAutoCompleteHome returns the auto_complete home of goctl.

func GetCacheDir

func GetCacheDir() (string, error)

GetCacheDir returns the cache dit of goctl.

func GetDefaultHome

func GetDefaultHome() (string, error)

GetDefaultHome returns the path value of the goctl home where Join $HOME with .goctl.

func GetGitHome

func GetGitHome() (string, error)

GetGitHome returns the git home of goctl.

func GetHome

func GetHome() (home string, err error)

GetHome returns the path value of the go-smart, the default path is ~/.go-smart, if the path has been set by calling the RegisterGocliHome method, the user-defined path refers to.

func GetTemplateDir

func GetTemplateDir(category string) (string, error)

GetTemplateDir returns the category path value in GoctlHome where could get it by GetHome.

func Hash

func Hash(file string) (string, error)

func InitTemplates

func InitTemplates(category string, templates map[string]string) error

InitTemplates creates template files GoctlHome where could get it by GetHome.

func JoinPackages

func JoinPackages(pkgs ...string) string

JoinPackages calls strings.Join and returns

func LoadTemplate

func LoadTemplate(category, file, builtin string) (string, error)

LoadTemplate gets template content by the specified file.

func MkdirIfNotExist

func MkdirIfNotExist(dir string) error

MkdirIfNotExist makes directories if the input path is not exists

func MustTempDir

func MustTempDir() string

MustTempDir creates a temporary directory.

func PathFromGoSrc

func PathFromGoSrc() (string, error)

PathFromGoSrc returns the path without slash where has been trim the prefix $GOPATH

func ReadLink(name string) (string, error)

ReadLink returns the destination of the named symbolic link recursively.

func RegisterGocliHome

func RegisterGocliHome(home string)

RegisterGocliHome register goctl home path.

func RemoveIfExist

func RemoveIfExist(filename string) error

RemoveIfExist deletes the specified file if it is exists.

func RemoveOrQuit

func RemoveOrQuit(filename string) error

RemoveOrQuit deletes the specified file if read a permit command from stdin.

func SameFile

func SameFile(path1, path2 string) (bool, error)

SameFile compares the between path if the same path, it maybe the same path in case case-ignore, such as: /Users/go_zero and /Users/Go_zero, as far as we know, this case maybe appear on macOS and Windows.

Types

This section is empty.

Jump to

Keyboard shortcuts

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