pathx

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: Apache-2.0 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 returns 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 goctlwt.

func GetCacheDir

func GetCacheDir() (string, error)

GetCacheDir returns the cache dit of goctlwt.

func GetDefaultGoctlHome

func GetDefaultGoctlHome() (string, error)

GetDefaultGoctlHome returns the path value of the goctlwt home where Join $HOME with .goctlwt.

func GetGitHome

func GetGitHome() (string, error)

GetGitHome returns the git home of goctlwt.

func GetGoctlHome

func GetGoctlHome() (home string, err error)

GetGoctlHome returns the path value of the goctlwt, the default path is ~/.goctlwt, if the path has been set by calling the RegisterGoctlHome 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 GetGoctlHome.

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 GetGoctlHome.

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 RegisterGoctlHome

func RegisterGoctlHome(home string)

RegisterGoctlHome register goctlwt 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