file_util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildFunctionCallExpr

func BuildFunctionCallExpr(pkgName string, funcName string, args []ast.Expr) *ast.CallExpr

BuildFunctionCallExpr 构建函数调用表达式

func GetAllFiles

func GetAllFiles(dir string) ([]string, error)

GetAllFiles 获取指定目录下的所有文件

func GetCurrentFileAbsPath

func GetCurrentFileAbsPath() (string, bool)

GetCurrentFileAbsPath returns the current file absolute path

func GetProjectAbsPath

func GetProjectAbsPath() (path string, ok error)

GetProjectAbsPath returns the project absolute path

func ParseFile

func ParseFile(filePath string, f func(n ast.Node) bool) (err error)

ParseFile 解析文件

Types

type File

type File struct {
	Path string // package path
}

func NewFile

func NewFile(path string) *File

func (*File) GetAbsPath

func (_this *File) GetAbsPath() (string, error)

GetAbsPath returns the absolute path

func (*File) GetDirAllFiles

func (_this *File) GetDirAllFiles() ([]string, error)

GetDirAllFiles returns all the files in the fileDirPath

func (*File) GetDirPath

func (_this *File) GetDirPath() (string, error)

GetDirPath returns the dir absolute path

func (*File) GetFileExt

func (_this *File) GetFileExt() string

GetFileExt returns the absolute path

func (*File) GetFileName

func (_this *File) GetFileName() string

GetFileName returns the absolute path

func (*File) Inspect

func (_this *File) Inspect(f func(n ast.Node) bool) (err error)

Inspect the file

func (*File) InspectMethods

func (_this *File) InspectMethods(f func(funcDecl *ast.FuncDecl) bool) (err error)

InspectMethods inspect methods

func (*File) IsAbs

func (_this *File) IsAbs() bool

IsAbs returns whether the path is an absolute path

func (*File) IsDir

func (_this *File) IsDir() (bool, error)

IsDir returns check whether the file is a directory

func (*File) IsFile

func (_this *File) IsFile() (bool, error)

IsFile returns check whether the file is a file

func (*File) Open

func (_this *File) Open() (*os.File, error)

Open returns the os.File

func (*File) OpenFile

func (_this *File) OpenFile(flag int, perm os.FileMode) (*os.File, error)

OpenFile returns the os.OpenFile

func (*File) OpenFileFunc

func (_this *File) OpenFileFunc(flag int, perm os.FileMode, action func(*os.File) error) (err error)

OpenFileFunc use the os.OpenFile function to open the file

func (*File) OpenFunc

func (_this *File) OpenFunc(action func(*os.File) error) (err error)

OpenFunc use the os.Open function to open the file

func (*File) ParseFile

func (_this *File) ParseFile() (f *ast.File, err error)

ParseFile parse the file

func (*File) WalkDir

func (_this *File) WalkDir(f func(path string, info os.FileInfo, err error) error) (err error)

WalkDir walk the fileDirPath

Jump to

Keyboard shortcuts

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