serialize

package
v0.26.9 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 7 Imported by: 3

Documentation

Overview

Package serialize 提供对 message 包的序列化操作

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFS

func LoadFS(fsys fs.FS, name string, u UnmarshalFunc) (*message.Language, error)

func LoadFSGlob

func LoadFSGlob(s Search, glob string, fsys ...fs.FS) ([]*message.Language, error)

LoadFSGlob 批量加载文件

相同语言 ID 的项会合并。

func LoadFile

func LoadFile(path string, u UnmarshalFunc) (*message.Language, error)

func LoadGlob

func LoadGlob(s Search, glob string) ([]*message.Language, error)

LoadGlob 批量加载文件

相同语言 ID 的项会合并。

func Marshal

func Marshal(l *message.Language, f MarshalFunc) ([]byte, error)

Marshal 将 l 转换为 []byte

func SaveFile

func SaveFile(l *message.Language, path string, f MarshalFunc, mode fs.FileMode) error

SaveFile 将 l 编码为文本并存入 path

如果文件已经存在会被覆盖。

func SaveFiles

func SaveFiles(langs []*message.Language, dir, ext string, f MarshalFunc, mode fs.FileMode) error

SaveFiles 将 langs 按语言 ID 分类保存

func Unmarshal

func Unmarshal(data []byte, u UnmarshalFunc) (*message.Language, error)

Unmarshal 加载内容

Types

type MarshalFunc

type MarshalFunc = func(any) ([]byte, error)
type Search = func(string) UnmarshalFunc

Search 根据文件名查找解码的方法

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