pathx

package
v1.2.6-0...-d584b8d Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: MIT Imports: 11 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 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 GetGitHome

func GetGitHome() (string, error)

GetGitHome returns the git home of goctl.

func GetGoctlHome

func GetGoctlHome() (string, error)

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

func GetTemplateDir

func GetTemplateDir(category string) (string, error)

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

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