files

package
v0.73.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package files 配置文件管理

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadLocales

func LoadLocales(f *Files, b *catalog.Builder, fsys fs.FS, glob string) error

Types

type Files

type Files struct {
	// contains filtered or unexported fields
}

Files 配置文件管理

func New

func New(fsys fs.FS) *Files

func (*Files) Add

func (f *Files) Add(m MarshalFunc, u UnmarshalFunc, ext ...string)

Add 添加新的序列方法

ext 为文件扩展名,需要带 . 符号;

func (*Files) Delete

func (f *Files) Delete(ext ...string)

Delete 删除序列化方法

func (*Files) Len

func (f *Files) Len() int

func (*Files) Load

func (f *Files) Load(fsys fs.FS, name string, v any) error

Load 加载指定名称的文件内容至 v

根据文件扩展名决定采用什么编码方法;

func (*Files) Save

func (f *Files) Save(path string, v any) error

Save 将 v 解码并保存至 name 中

根据文件扩展名决定采用什么编码方法;

type MarshalFunc

type MarshalFunc func(any) ([]byte, error)

type Serializer added in v0.70.0

type Serializer struct {
	Marshal   MarshalFunc
	Unmarshal UnmarshalFunc
}

type UnmarshalFunc

type UnmarshalFunc func([]byte, any) error

Jump to

Keyboard shortcuts

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