fo

package
v0.0.0-...-2aa3bab Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cat

func Cat(file string, trim bool, fallbackFiles ...string) string

Cat 读取文件,输出文件文本内容

  • noTrim: 不删除内容前后空白(默认是删除的)
  • fallbackFiles: 找不到文件时,尝试读取这些文件

func FlagAppend

func FlagAppend(o *options)

创建文件时候的 flag, 追加模式

func FlagRw

func FlagRw(o *options)

创建文件时候的 flag, 读写模式 (read and write)

func FlagTrunc

func FlagTrunc(o *options)

创建文件时候的 flag, 覆盖模式

func FlagWo

func FlagWo(o *options)

创建文件时候的 flag, 只写模式(write only)

func Nop

func Nop(w *os.File) error

什么都不干

func OpenRead

func OpenRead(name string, process Process, options ...Option) (err error)

OpenRead 读取

func OpenWrite

func OpenWrite(name string, process Process, options ...Option) (err error)

OpenWrite 写入

func WalkDir

func WalkDir(root string, fn func(path string, d fs.DirEntry) error) error

Types

type Option

type Option func(*options)

Option 创建文件时候的选项

func DirPerm

func DirPerm(perm fs.FileMode) Option

DirPerm 创建文件时,如果上级目录不存在,会自动创建,该值指向创建这些目录时所设置的权限

func Flag

func Flag(flag int) Option

Flag 创建文件时候的 flag

func FlagExcl

func FlagExcl(existOk bool) Option

FlagExcl 创建文件时候如果文件已存在则返回错误,如果同时 existOK 为 true 则忽略该错误,且什么都不会做。

func Perm

func Perm(perm fs.FileMode) Option

Perm 创建文件时候的权限

func PermFrom

func PermFrom(r *os.File) Option

从文件中获取权限信息,设置到新文件中,只在新创建的文件中生效

type Process

type Process func(*os.File) (err error)

func Content

func Content[T ~string | ~[]byte](content T) Process

将内容写入到打开的文件

func From

func From(r io.Reader) Process

From 将源r写入到文件

func FromFile

func FromFile(from string, options ...Option) Process

FromFile 从文件读取并写入到打开的文件

func Lines

func Lines[T ~string | ~[]byte](lines ...T) Process

将内容行写入到打开的文件

func To

func To(w io.Writer) Process

To 将读取的文件写入到w

func ToFile

func ToFile(to string, options ...Option) Process

To File 将读取的文件写入到文件

Jump to

Keyboard shortcuts

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