pack

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2020 License: MIT Imports: 12 Imported by: 1

README

pack Test Status codecov go.dev reference license

用于将数据对象打包成一个 Go 文件

type Object{
    // fields
}

o := &Object{}

// 在 ./static.go 文件生成 Obj 常量,其内容为编码后的 o 内容。
// 该内容可通过 Unpack 解码。
pack.File(o, "static", "Obj", "NOT EDIT", "","./static.go")

安装

go get github.com/issue9/pack

版权

本项目采用 MIT 开源授权许可证,完整的授权说明可在 LICENSE 文件中找到。

Documentation

Overview

Package pack 用于将数据资源打包为 Go 文件

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes

func Bytes(v interface{}) ([]byte, error)

Bytes 将 v 打包成一份合法的 Go []byte 类型

func DirBytes added in v0.2.0

func DirBytes(root string) ([]byte, error)

DirBytes 打包 dir 下所有的文件内容

func DirFile added in v0.2.0

func DirFile(root string, pkgName, varName, fileHeader, tag, path string) error

DirFile 打包 dir 下所有的文件内容

func DirString added in v0.2.0

func DirString(root string) (string, error)

DirString 打包 dir 下所有的文件内容

func File

func File(v interface{}, pkgName, varName, fileHeader, tag, path string) error

File 将对象 v 打包成一个 Go 文件内容中

pkgName 和 varName 分别指定包名和变量名; fileHeader 指定了文件头,如果为空,则不会输出文件内容; tag 指定了 // +build 指令下的标签,如果为空则不生成该指令;

func NewFileSystem added in v0.2.0

func NewFileSystem(data string) (http.FileSystem, error)

NewFileSystem 将 data 解包并生成符合 http.FileSystem 接口的实例

data 必须是由 DirBytes 或是 DirString 打包后的数据。

func String

func String(v interface{}) (string, error)

String 将 v 打包成一份合法的 Go 字符串

func Unpack

func Unpack(data string, v interface{}) error

Unpack 用于解压由 Bytes 或是 String 打包的内容

Types

This section is empty.

Jump to

Keyboard shortcuts

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