Documentation ¶
Index ¶
- Constants
- Variables
- func CacheInit()
- func ClearCache()
- func CopyChangedDataFiles(fName string) error
- func CopyChangedProtoFiles(fName string) error
- func IsDataChanged(ps *ProtoSheet) bool
- func IsProtoChanged(ps *ProtoSheet) bool
- func IsSheetExists(xlsxName string) bool
- func IsTitleValid(title string) bool
- func IsXlsxChanged(filename string) bool
- func ReadSheet(fileName, sheetName string) error
- func ResetConfigCache()
- func Run(isCacheOn, isUseGoroutine bool)
- type CConfig
- type CacheStatus
- type Cacher
- type CommonInfo
- type Config
- type DataInfo
- type OptStruct
- type ProtoIn
- type ProtoOut
- type ProtoSheet
- func (pr *ProtoSheet) AddMessageArray()
- func (pr *ProtoSheet) AddMessageHead(name string)
- func (pr *ProtoSheet) AddMessageTail()
- func (pr *ProtoSheet) AddOneDefine(isRepeat bool, comment, p2type, typ, name, defaultValStr string, idx int)
- func (pr *ProtoSheet) AddOneEmptyLine()
- func (pr *ProtoSheet) AddOptStructTail(opts *OptStruct)
- func (pr *ProtoSheet) AddOptionalStruct(optS *OptStruct)
- func (pr *ProtoSheet) AddPreHead()
- func (pr *ProtoSheet) AddRepeat(repeat *Repeat)
- func (pr *ProtoSheet) AddRepeatTail(repeat *Repeat)
- func (pr *ProtoSheet) AddVal(sh *Val)
- func (pr *ProtoSheet) DataHash()
- func (pr *ProtoSheet) DecreaseIndent()
- func (pr *ProtoSheet) GenProto()
- func (pr *ProtoSheet) IncreaseIndent()
- func (pr *ProtoSheet) ProtoHash()
- func (pr *ProtoSheet) WriteData()
- func (pr *ProtoSheet) WriteProto()
- type Repeat
- type Val
Constants ¶
const ( RowAttr = iota RowType RowID RowComment RowData )
Row index in sheet
const ( Req = "required" Opt = "optional" Rep = "repeated" OptStru = "optional_struct" Unique = "unique" )
Field type for proto2
Variables ¶
var ( ErrRequiredFieldEmpty = errors.New("required field is empty") ErrFormatInvalid = errors.New("invalid cell value") )
var (
// INDENT Use 2 spaces
INDENT = " "
)
Functions ¶
func CopyChangedDataFiles ¶
CopyChangedDataFiles if a data file is changed, copy data file to output dir
func CopyChangedProtoFiles ¶
CopyChangedProtoFiles if a proto file is changed, copy both proto and data file to output dir
func IsDataChanged ¶
func IsDataChanged(ps *ProtoSheet) bool
func IsProtoChanged ¶
func IsProtoChanged(ps *ProtoSheet) bool
IsProtoChanged check and update previous proto info
func IsSheetExists ¶
IsSheetExists check if file exist in xlsx folder
func IsTitleValid ¶
IsTitleValid check if the first letter of a xlsx title is uppercase.
func IsXlsxChanged ¶
IsXlsxChanged check if file has the same hash value as before
Types ¶
type Cacher ¶
type Cacher struct { XlsxInfos map[string]*DataInfo `json:"xlsx_info"` ProtoInfos map[string]*DataInfo `json:"proto_info"` DataInfos map[string]*DataInfo `json:"data_info"` // contains filtered or unexported fields }
Cacher is handler for cache
type CommonInfo ¶
type CommonInfo struct {
// contains filtered or unexported fields
}
CommonInfo is common info for val, opt struct and repeat
type Config ¶
type Config struct { ConfigRegExp string `toml:"config_reg_exp"` XlsxPath string `toml:"xlsx_path"` XlsxExt string `toml:"xlsx_ext"` PackageName string `toml:"package_name"` UseProto3 bool `toml:"use_proto3"` ProtoOutPath string `toml:"proto_path"` ProtoOutExt string `toml:"proto_ext"` DataOutPath string `toml:"data_path"` DataOutExt string `toml:"data_ext"` CacheFile string `toml:"cache_file"` ChangeOutputPath string `toml:"change_output_path"` ChangeLog string `toml:"change_log"` }
func (*Config) LoadConfig ¶
func (c *Config) LoadConfig()
func (*Config) ReplaceRelPaths ¶
func (c *Config) ReplaceRelPaths()
type DataInfo ¶
type DataInfo struct { Name string `json:"name"` MD5 []byte `json:"md5"` State CacheStatus `json:"-"` // 0: previous 1: updated 2: new }
XlsxInfo contains sheet information in xlsx files
type OptStruct ¶
type OptStruct struct { CommonInfo // contains filtered or unexported fields }
OptStruct is a struct contains one or more variants
type ProtoIn ¶
type ProtoIn struct { Name string // contains filtered or unexported fields }
ProtoIn contains data read from xlsx
type ProtoOut ¶
type ProtoOut struct {
// contains filtered or unexported fields
}
ProtoOut controls how to output proto file
type ProtoSheet ¶
ProtoSheet is used to generate proto file buf used to store data binary
func (*ProtoSheet) AddMessageArray ¶
func (pr *ProtoSheet) AddMessageArray()
AddMessageArray add an array for current message as XXX_ARRAY
func (*ProtoSheet) AddMessageHead ¶
func (pr *ProtoSheet) AddMessageHead(name string)
AddMessageHead add a proto message head
func (*ProtoSheet) AddMessageTail ¶
func (pr *ProtoSheet) AddMessageTail()
AddMessageTail add a proto message tail
func (*ProtoSheet) AddOneDefine ¶
func (pr *ProtoSheet) AddOneDefine(isRepeat bool, comment, p2type, typ, name, defaultValStr string, idx int)
AddOneDefine add a proto defination
func (*ProtoSheet) AddOneEmptyLine ¶
func (pr *ProtoSheet) AddOneEmptyLine()
AddOneEmptyLine add an empty line
func (*ProtoSheet) AddOptStructTail ¶
func (pr *ProtoSheet) AddOptStructTail(opts *OptStruct)
func (*ProtoSheet) AddOptionalStruct ¶
func (pr *ProtoSheet) AddOptionalStruct(optS *OptStruct)
func (*ProtoSheet) AddPreHead ¶
func (pr *ProtoSheet) AddPreHead()
AddPreHead add syntax and package info
func (*ProtoSheet) AddRepeat ¶
func (pr *ProtoSheet) AddRepeat(repeat *Repeat)
AddRepeat add repeat struct
func (*ProtoSheet) AddRepeatTail ¶
func (pr *ProtoSheet) AddRepeatTail(repeat *Repeat)
AddRepeatTail add repeat declare
func (*ProtoSheet) AddVal ¶
func (pr *ProtoSheet) AddVal(sh *Val)
AddVal add a proto variable define
func (*ProtoSheet) DecreaseIndent ¶
func (pr *ProtoSheet) DecreaseIndent()
DecreaseIndent decrease indent
func (*ProtoSheet) IncreaseIndent ¶
func (pr *ProtoSheet) IncreaseIndent()
IncreaseIndent increase indent
func (*ProtoSheet) ProtoHash ¶
func (pr *ProtoSheet) ProtoHash()
Hash generate hash of proto content
func (*ProtoSheet) WriteData ¶
func (pr *ProtoSheet) WriteData()
func (*ProtoSheet) WriteProto ¶
func (pr *ProtoSheet) WriteProto()
WriteProto output proto file to "./proto/sheetname.proto"
type Repeat ¶
type Repeat struct { CommonInfo // contains filtered or unexported fields }
Repeat contains repeat fields for .proto file
type Val ¶
type Val struct { CommonInfo // contains filtered or unexported fields }
Val contains fields for .proto file