serialize

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 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.File, error)

func LoadFSGlob

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

LoadFSGlob 批量加载文件

func LoadFile

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

func LoadGlob

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

LoadGlob 批量加载文件

func Marshal

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

Marshal 将 l 转换为 []byte

func SaveFile

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

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

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

func Unmarshal

func Unmarshal(data []byte, u UnmarshalFunc) (*message.File, 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