pce

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 9 Imported by: 0

README

Pce

Go doc

暂无介绍...

目录导航

列出了该 package 下所有的函数及类型定义,可通过目录导航进行快捷跳转 ❤️

展开 / 折叠目录导航

包级函数定义

函数名称 描述
NewExporter 创建导出器
GetFieldGolangType 获取字段的 Golang 类型
GetFields 获取所有内置支持的字段
NewLoader 创建加载器

类型定义

类型 名称 描述
INTERFACE Config 配置解析接口
INTERFACE DataTmpl 数据导出模板
STRUCT Exporter 导出器
INTERFACE Field 基本字段类型接口
STRUCT Int 暂无描述...
STRUCT Int8 暂无描述...
STRUCT Int16 暂无描述...
STRUCT Int32 暂无描述...
STRUCT Int64 暂无描述...
STRUCT Uint 暂无描述...
STRUCT Uint8 暂无描述...
STRUCT Uint16 暂无描述...
STRUCT Uint32 暂无描述...
STRUCT Uint64 暂无描述...
STRUCT Float32 暂无描述...
STRUCT Float64 暂无描述...
STRUCT String 暂无描述...
STRUCT Bool 暂无描述...
STRUCT Byte 暂无描述...
STRUCT Rune 暂无描述...
STRUCT Complex64 暂无描述...
STRUCT Complex128 暂无描述...
STRUCT Uintptr 暂无描述...
STRUCT Double 暂无描述...
STRUCT Float 暂无描述...
STRUCT Long 暂无描述...
STRUCT Short 暂无描述...
STRUCT Char 暂无描述...
STRUCT Number 暂无描述...
STRUCT Integer 暂无描述...
STRUCT Boolean 暂无描述...
STRUCT Loader 配置加载器
STRUCT DataInfo 配置数据
STRUCT DataField 配置数据字段
INTERFACE Tmpl 配置结构模板接口
STRUCT TmplField 模板字段
STRUCT TmplStruct 模板结构

详情信息

func NewExporter() *Exporter

创建导出器


func GetFieldGolangType(field Field) string

获取字段的 Golang 类型

查看 / 收起单元测试

func TestGetFieldGolangType(t *testing.T) {
	fmt.Println(pce.GetFieldGolangType(new(pce.String)))
}


func GetFields() []Field

获取所有内置支持的字段


func NewLoader(fields []Field) *Loader

创建加载器

  • 加载器被用于加载配置表的数据和结构信息

Config INTERFACE

配置解析接口

  • 用于将配置文件解析为可供分析的数据结构
  • 可以在 cs 包中找到内置提供的实现及其模板,例如 cs.XlsxIndexConfig
type Config interface {
	GetConfigName() string
	GetDisplayName() string
	GetDescription() string
	GetIndexCount() int
	GetFields() []DataField
	GetData() [][]DataInfo
}

DataTmpl INTERFACE

数据导出模板

type DataTmpl interface {
	Render(data map[any]any) (string, error)
}

Exporter STRUCT

导出器

type Exporter struct{}

func (*Exporter) ExportStruct(tmpl Tmpl, tmplStruct ...*TmplStruct) ( []byte, error)

导出结构


func (*Exporter) ExportData(tmpl DataTmpl, data map[any]any) ( []byte, error)

导出数据


Field INTERFACE

基本字段类型接口

type Field interface {
	TypeName() string
	Zero() any
	Parse(value string) any
}

Int STRUCT
type Int int

func (Int) TypeName() string

func (Int) Zero() any

func (Int) Parse(value string) any

Int8 STRUCT
type Int8 int8

func (Int8) TypeName() string

func (Int8) Zero() any

func (Int8) Parse(value string) any

Int16 STRUCT
type Int16 int16

func (Int16) TypeName() string

func (Int16) Zero() any

func (Int16) Parse(value string) any

Int32 STRUCT
type Int32 int32

func (Int32) TypeName() string

func (Int32) Zero() any

func (Int32) Parse(value string) any

Int64 STRUCT
type Int64 int64

func (Int64) TypeName() string

func (Int64) Zero() any

func (Int64) Parse(value string) any

Uint STRUCT
type Uint uint

func (Uint) TypeName() string

func (Uint) Zero() any

func (Uint) Parse(value string) any

Uint8 STRUCT
type Uint8 uint8

func (Uint8) TypeName() string

func (Uint8) Zero() any

func (Uint8) Parse(value string) any

Uint16 STRUCT
type Uint16 uint16

func (Uint16) TypeName() string

func (Uint16) Zero() any

func (Uint16) Parse(value string) any

Uint32 STRUCT
type Uint32 uint32

func (Uint32) TypeName() string

func (Uint32) Zero() any

func (Uint32) Parse(value string) any

Uint64 STRUCT
type Uint64 uint64

func (Uint64) TypeName() string

func (Uint64) Zero() any

func (Uint64) Parse(value string) any

Float32 STRUCT
type Float32 float32

func (Float32) TypeName() string

func (Float32) Zero() any

func (Float32) Parse(value string) any

Float64 STRUCT
type Float64 float64

func (Float64) TypeName() string

func (Float64) Zero() any

func (Float64) Parse(value string) any

String STRUCT
type String string

func (String) TypeName() string

func (String) Zero() any

func (String) Parse(value string) any

Bool STRUCT
type Bool bool

func (Bool) TypeName() string

func (Bool) Zero() any

func (Bool) Parse(value string) any

Byte STRUCT
type Byte byte

func (Byte) TypeName() string

func (Byte) Zero() any

func (Byte) Parse(value string) any

Rune STRUCT
type Rune rune

func (Rune) TypeName() string

func (Rune) Zero() any

func (Rune) Parse(value string) any

Complex64 STRUCT
type Complex64 complex64

func (Complex64) TypeName() string

func (Complex64) Zero() any

func (Complex64) Parse(value string) any

Complex128 STRUCT
type Complex128 complex128

func (Complex128) TypeName() string

func (Complex128) Zero() any

func (Complex128) Parse(value string) any

Uintptr STRUCT
type Uintptr uintptr

func (Uintptr) TypeName() string

func (Uintptr) Zero() any

func (Uintptr) Parse(value string) any

Double STRUCT
type Double float64

func (Double) TypeName() string

func (Double) Zero() any

func (Double) Parse(value string) any

Float STRUCT
type Float float32

func (Float) TypeName() string

func (Float) Zero() any

func (Float) Parse(value string) any

Long STRUCT
type Long int64

func (Long) TypeName() string

func (Long) Zero() any

func (Long) Parse(value string) any

Short STRUCT
type Short int16

func (Short) TypeName() string

func (Short) Zero() any

func (Short) Parse(value string) any

Char STRUCT
type Char int8

func (Char) TypeName() string

func (Char) Zero() any

func (Char) Parse(value string) any

Number STRUCT
type Number float64

func (Number) TypeName() string

func (Number) Zero() any

func (Number) Parse(value string) any

Integer STRUCT
type Integer int64

func (Integer) TypeName() string

func (Integer) Zero() any

func (Integer) Parse(value string) any

Boolean STRUCT
type Boolean bool

func (Boolean) TypeName() string

func (Boolean) Zero() any

func (Boolean) Parse(value string) any

Loader STRUCT

配置加载器

type Loader struct {
	fields map[string]Field
}

func (*Loader) LoadStruct(config Config) *TmplStruct

加载结构


func (*Loader) LoadData(config Config) map[any]any

加载配置并得到配置数据


DataInfo STRUCT

配置数据

type DataInfo struct {
	DataField
	Value string
}

DataField STRUCT

配置数据字段

type DataField struct {
	Index      int
	Name       string
	Desc       string
	Type       string
	ExportType string
}

Tmpl INTERFACE

配置结构模板接口

type Tmpl interface {
	Render(templates ...*TmplStruct) (string, error)
}

TmplField STRUCT

模板字段

type TmplField struct {
	Name    string
	Desc    string
	Type    string
	Struct  *TmplStruct
	Index   int
	slice   bool
	isIndex bool
}

func (*TmplField) IsIndex() bool

是否是索引字段


func (*TmplField) IsStruct() bool

是否是结构类型


func (*TmplField) IsSlice() bool

是否是切片类型


TmplStruct STRUCT

模板结构

type TmplStruct struct {
	Name       string
	Desc       string
	Fields     []*TmplField
	IndexCount int
}

func (*TmplStruct) AllChildren() []*TmplStruct

获取所有子结构


Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFieldGolangType

func GetFieldGolangType(field Field) string

GetFieldGolangType 获取字段的 Golang 类型

Types

type Bool

type Bool bool

func (Bool) Parse

func (slf Bool) Parse(value string) any

func (Bool) TypeName

func (slf Bool) TypeName() string

func (Bool) Zero

func (slf Bool) Zero() any

type Boolean

type Boolean bool

func (Boolean) Parse

func (slf Boolean) Parse(value string) any

func (Boolean) TypeName

func (slf Boolean) TypeName() string

func (Boolean) Zero

func (slf Boolean) Zero() any

type Byte

type Byte byte

func (Byte) Parse

func (slf Byte) Parse(value string) any

func (Byte) TypeName

func (slf Byte) TypeName() string

func (Byte) Zero

func (slf Byte) Zero() any

type Char

type Char int8

func (Char) Parse

func (slf Char) Parse(value string) any

func (Char) TypeName

func (slf Char) TypeName() string

func (Char) Zero

func (slf Char) Zero() any

type Complex128

type Complex128 complex128

func (Complex128) Parse

func (slf Complex128) Parse(value string) any

func (Complex128) TypeName

func (slf Complex128) TypeName() string

func (Complex128) Zero

func (slf Complex128) Zero() any

type Complex64

type Complex64 complex64

func (Complex64) Parse

func (slf Complex64) Parse(value string) any

func (Complex64) TypeName

func (slf Complex64) TypeName() string

func (Complex64) Zero

func (slf Complex64) Zero() any

type Config

type Config interface {
	// GetConfigName 配置名称
	GetConfigName() string
	// GetDisplayName 配置显示名称
	GetDisplayName() string
	// GetDescription 配置描述
	GetDescription() string
	// GetIndexCount 索引数量
	GetIndexCount() int
	// GetFields 获取字段
	GetFields() []DataField
	// GetData 获取数据
	GetData() [][]DataInfo
}

Config 配置解析接口

  • 用于将配置文件解析为可供分析的数据结构
  • 可以在 cs 包中找到内置提供的实现及其模板,例如 cs.XlsxIndexConfig

type DataField

type DataField struct {
	Index      int    // 字段索引
	Name       string // 字段名称
	Desc       string // 字段描述
	Type       string // 字段类型
	ExportType string // 导出类型
}

DataField 配置数据字段

type DataInfo

type DataInfo struct {
	DataField        // 字段
	Value     string // 字段值
}

DataInfo 配置数据

type DataTmpl

type DataTmpl interface {
	// Render 渲染模板
	Render(data map[any]any) (string, error)
}

DataTmpl 数据导出模板

type Double

type Double float64

func (Double) Parse

func (slf Double) Parse(value string) any

func (Double) TypeName

func (slf Double) TypeName() string

func (Double) Zero

func (slf Double) Zero() any

type Exporter

type Exporter struct{}

Exporter 导出器

func NewExporter

func NewExporter() *Exporter

NewExporter 创建导出器

func (*Exporter) ExportData

func (slf *Exporter) ExportData(tmpl DataTmpl, data map[any]any) ([]byte, error)

ExportData 导出数据

func (*Exporter) ExportStruct

func (slf *Exporter) ExportStruct(tmpl Tmpl, tmplStruct ...*TmplStruct) ([]byte, error)

ExportStruct 导出结构

type Field

type Field interface {
	// TypeName 字段类型名称
	TypeName() string
	// Zero 获取零值
	Zero() any
	// Parse 解析
	Parse(value string) any
}

Field 基本字段类型接口

func GetFields

func GetFields() []Field

GetFields 获取所有内置支持的字段

type Float

type Float float32

func (Float) Parse

func (slf Float) Parse(value string) any

func (Float) TypeName

func (slf Float) TypeName() string

func (Float) Zero

func (slf Float) Zero() any

type Float32

type Float32 float32

func (Float32) Parse

func (slf Float32) Parse(value string) any

func (Float32) TypeName

func (slf Float32) TypeName() string

func (Float32) Zero

func (slf Float32) Zero() any

type Float64

type Float64 float64

func (Float64) Parse

func (slf Float64) Parse(value string) any

func (Float64) TypeName

func (slf Float64) TypeName() string

func (Float64) Zero

func (slf Float64) Zero() any

type Int

type Int int

func (Int) Parse

func (slf Int) Parse(value string) any

func (Int) TypeName

func (slf Int) TypeName() string

func (Int) Zero

func (slf Int) Zero() any

type Int16

type Int16 int16

func (Int16) Parse

func (slf Int16) Parse(value string) any

func (Int16) TypeName

func (slf Int16) TypeName() string

func (Int16) Zero

func (slf Int16) Zero() any

type Int32

type Int32 int32

func (Int32) Parse

func (slf Int32) Parse(value string) any

func (Int32) TypeName

func (slf Int32) TypeName() string

func (Int32) Zero

func (slf Int32) Zero() any

type Int64

type Int64 int64

func (Int64) Parse

func (slf Int64) Parse(value string) any

func (Int64) TypeName

func (slf Int64) TypeName() string

func (Int64) Zero

func (slf Int64) Zero() any

type Int8

type Int8 int8

func (Int8) Parse

func (slf Int8) Parse(value string) any

func (Int8) TypeName

func (slf Int8) TypeName() string

func (Int8) Zero

func (slf Int8) Zero() any

type Integer

type Integer int64

func (Integer) Parse

func (slf Integer) Parse(value string) any

func (Integer) TypeName

func (slf Integer) TypeName() string

func (Integer) Zero

func (slf Integer) Zero() any

type Loader

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

Loader 配置加载器

func NewLoader

func NewLoader(fields []Field) *Loader

NewLoader 创建加载器

  • 加载器被用于加载配置表的数据和结构信息

func (*Loader) LoadData

func (slf *Loader) LoadData(config Config) map[any]any

LoadData 加载配置并得到配置数据

func (*Loader) LoadStruct

func (slf *Loader) LoadStruct(config Config) *TmplStruct

LoadStruct 加载结构

type Long

type Long int64

func (Long) Parse

func (slf Long) Parse(value string) any

func (Long) TypeName

func (slf Long) TypeName() string

func (Long) Zero

func (slf Long) Zero() any

type Number

type Number float64

func (Number) Parse

func (slf Number) Parse(value string) any

func (Number) TypeName

func (slf Number) TypeName() string

func (Number) Zero

func (slf Number) Zero() any

type Rune

type Rune rune

func (Rune) Parse

func (slf Rune) Parse(value string) any

func (Rune) TypeName

func (slf Rune) TypeName() string

func (Rune) Zero

func (slf Rune) Zero() any

type Short

type Short int16

func (Short) Parse

func (slf Short) Parse(value string) any

func (Short) TypeName

func (slf Short) TypeName() string

func (Short) Zero

func (slf Short) Zero() any

type String

type String string

func (String) Parse

func (slf String) Parse(value string) any

func (String) TypeName

func (slf String) TypeName() string

func (String) Zero

func (slf String) Zero() any

type Tmpl

type Tmpl interface {
	// Render 渲染模板
	Render(templates ...*TmplStruct) (string, error)
}

Tmpl 配置结构模板接口

type TmplField

type TmplField struct {
	Name   string      // 字段名称
	Desc   string      // 字段描述
	Type   string      // 字段类型
	Struct *TmplStruct // 结构类型字段结构信息
	Index  int         // 字段索引
	// contains filtered or unexported fields
}

TmplField 模板字段

func (*TmplField) IsIndex

func (slf *TmplField) IsIndex() bool

IsIndex 是否是索引字段

func (*TmplField) IsSlice

func (slf *TmplField) IsSlice() bool

IsSlice 是否是切片类型

func (*TmplField) IsStruct

func (slf *TmplField) IsStruct() bool

IsStruct 是否是结构类型

type TmplStruct

type TmplStruct struct {
	Name       string       // 结构名称
	Desc       string       // 结构描述
	Fields     []*TmplField // 字段列表
	IndexCount int          // 索引数量
}

TmplStruct 模板结构

func (*TmplStruct) AllChildren

func (slf *TmplStruct) AllChildren() []*TmplStruct

AllChildren 获取所有子结构

type Uint

type Uint uint

func (Uint) Parse

func (slf Uint) Parse(value string) any

func (Uint) TypeName

func (slf Uint) TypeName() string

func (Uint) Zero

func (slf Uint) Zero() any

type Uint16

type Uint16 uint16

func (Uint16) Parse

func (slf Uint16) Parse(value string) any

func (Uint16) TypeName

func (slf Uint16) TypeName() string

func (Uint16) Zero

func (slf Uint16) Zero() any

type Uint32

type Uint32 uint32

func (Uint32) Parse

func (slf Uint32) Parse(value string) any

func (Uint32) TypeName

func (slf Uint32) TypeName() string

func (Uint32) Zero

func (slf Uint32) Zero() any

type Uint64

type Uint64 uint64

func (Uint64) Parse

func (slf Uint64) Parse(value string) any

func (Uint64) TypeName

func (slf Uint64) TypeName() string

func (Uint64) Zero

func (slf Uint64) Zero() any

type Uint8

type Uint8 uint8

func (Uint8) Parse

func (slf Uint8) Parse(value string) any

func (Uint8) TypeName

func (slf Uint8) TypeName() string

func (Uint8) Zero

func (slf Uint8) Zero() any

type Uintptr

type Uintptr uintptr

func (Uintptr) Parse

func (slf Uintptr) Parse(value string) any

func (Uintptr) TypeName

func (slf Uintptr) TypeName() string

func (Uintptr) Zero

func (slf Uintptr) Zero() any

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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