dlinux

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package dlinux

用于操作linux的函数集合

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(src, dst string, BUFFERSIZE int64) error

func Copy: 拷贝文件

src: 源文件

dst: 目的文件

BUFFERSIZE: 缓存大小

Example
src := "/root/1.txt"
dst := "/root/2.txt"
var buf int64 = 128
err := Copy(src, dst, buf)
if err != nil {
	log.Fatalln(err)
}
Output:
some io.Reader stream to be read

func PathExists

func PathExists(path string) (bool, error)

PathExists :golang判断文件或文件夹是否存在的方法为使用os.Stat()函数返回的错误值进行判断:

返回值:

true,nil: 如果返回的错误为nil,说明文件或文件夹存在
false,nil:说明文件或文件夹不存在
false,err: 如果返回的错误为其它类型,则不确定是否在存在
Example
exists, err := PathExists("/root/dingyz/xxx")
if err != nil {
	fmt.Printf("文件不确定是否存在,有报错:%s", err.Error())
	return
}
if exists {
	fmt.Println("文件存在")
} else {
	fmt.Println("文件不存在")

}
Output:
文件存在

Types

This section is empty.

Jump to

Keyboard shortcuts

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