style: 去除部分无用字段,优化整体可读性
This commit is contained in:
parent
1b9ec9f2b6
commit
c1e3c65c1c
|
@ -272,7 +272,7 @@ func (slf *Attrs) GetAttrInt64(id int) int64 {
|
||||||
case int32:
|
case int32:
|
||||||
return int64(value)
|
return int64(value)
|
||||||
case int64:
|
case int64:
|
||||||
return int64(value)
|
return value
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
)
|
)
|
||||||
|
@ -39,11 +40,12 @@ func New(xlsxPath string) *ConfigExport {
|
||||||
zap.String("Info", "Excluded non-configuration table files"),
|
zap.String("Info", "Excluded non-configuration table files"),
|
||||||
)
|
)
|
||||||
default:
|
default:
|
||||||
log.ErrorHideStack("ConfigExport",
|
log.Error("ConfigExport",
|
||||||
zap.String("File", xlsxPath),
|
zap.String("File", xlsxPath),
|
||||||
zap.String("Sheet", sheet.Name),
|
zap.String("Sheet", sheet.Name),
|
||||||
zap.String("Info", "Excluded non-configuration table files"),
|
zap.String("Info", "Excluded non-configuration table files"),
|
||||||
)
|
)
|
||||||
|
debug.PrintStack()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if config == nil {
|
if config == nil {
|
||||||
|
|
|
@ -9,8 +9,6 @@ var (
|
||||||
ErrReadConfigFailedWithName = errors.New("read config name failed, can not found position")
|
ErrReadConfigFailedWithName = errors.New("read config name failed, can not found position")
|
||||||
ErrReadConfigFailedWithIndexCount = errors.New("read config index count failed, can not found position")
|
ErrReadConfigFailedWithIndexCount = errors.New("read config index count failed, can not found position")
|
||||||
ErrReadConfigFailedWithIndexCountLessThanZero = errors.New("read config index count failed, value less than zero")
|
ErrReadConfigFailedWithIndexCountLessThanZero = errors.New("read config index count failed, value less than zero")
|
||||||
ErrReadConfigFailedWithFieldPosition = errors.New("read config index count failed, field position exception")
|
|
||||||
ErrReadConfigFailedWithNameDuplicate = errors.New("read config index count failed, duplicate field names")
|
ErrReadConfigFailedWithNameDuplicate = errors.New("read config index count failed, duplicate field names")
|
||||||
ErrReadConfigFailedWithExportParamException = errors.New("read config index count failed, export param must is s or c or sc or cs")
|
|
||||||
ErrReadConfigFailedWithIndexTypeException = errors.New("read config index count failed, the index type is only allowed to be the basic type")
|
ErrReadConfigFailedWithIndexTypeException = errors.New("read config index count failed, the index type is only allowed to be the basic type")
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,9 +9,9 @@ import (
|
||||||
// ReporterStrategy 上报器策略
|
// ReporterStrategy 上报器策略
|
||||||
type ReporterStrategy func(reporter *Reporter)
|
type ReporterStrategy func(reporter *Reporter)
|
||||||
|
|
||||||
// ReportStrategyLoop 循环上报
|
// StrategyLoop 循环上报
|
||||||
// - 将在创建后上报一次,并且在每隔一段时间后继续上报
|
// - 将在创建后上报一次,并且在每隔一段时间后继续上报
|
||||||
func ReportStrategyLoop(t time.Duration) ReporterStrategy {
|
func StrategyLoop(t time.Duration) ReporterStrategy {
|
||||||
return func(reporter *Reporter) {
|
return func(reporter *Reporter) {
|
||||||
reporter.ticker.Loop(fmt.Sprintf("ReportStrategyLoop_%d", t.Milliseconds()), timer.Instantly, t, timer.Forever, func() {
|
reporter.ticker.Loop(fmt.Sprintf("ReportStrategyLoop_%d", t.Milliseconds()), timer.Instantly, t, timer.Forever, func() {
|
||||||
if err := reporter.Report(); err != nil && reporter.errorHandle != nil {
|
if err := reporter.Report(); err != nil && reporter.errorHandle != nil {
|
||||||
|
@ -21,8 +21,8 @@ func ReportStrategyLoop(t time.Duration) ReporterStrategy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReportStrategyFixedTime 将在每天的固定时间上报
|
// StrategyFixedTime 将在每天的固定时间上报
|
||||||
func ReportStrategyFixedTime(hour, min, sec int) ReporterStrategy {
|
func StrategyFixedTime(hour, min, sec int) ReporterStrategy {
|
||||||
return func(reporter *Reporter) {
|
return func(reporter *Reporter) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
current := now.Unix()
|
current := now.Unix()
|
||||||
|
|
|
@ -146,7 +146,7 @@ func (slf *Map[Key, Value]) rangeFree(handle func(key Key, value Value, skip fun
|
||||||
|
|
||||||
func (slf *Map[Key, Value]) Keys() []Key {
|
func (slf *Map[Key, Value]) Keys() []Key {
|
||||||
var s = make([]Key, 0, len(slf.data))
|
var s = make([]Key, 0, len(slf.data))
|
||||||
for k, _ := range slf.data {
|
for k := range slf.data {
|
||||||
s = append(s, k)
|
s = append(s, k)
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
|
|
|
@ -102,10 +102,10 @@ func LineCount(filePath string) int {
|
||||||
return line
|
return line
|
||||||
}
|
}
|
||||||
|
|
||||||
// FilePaths 获取指定目录下的所有文件路径
|
// Paths 获取指定目录下的所有文件路径
|
||||||
// - 包括了子目录下的文件
|
// - 包括了子目录下的文件
|
||||||
// - 不包含目录
|
// - 不包含目录
|
||||||
func FilePaths(dir string) []string {
|
func Paths(dir string) []string {
|
||||||
var paths []string
|
var paths []string
|
||||||
abs, err := filepath.Abs(dir)
|
abs, err := filepath.Abs(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -119,7 +119,7 @@ func FilePaths(dir string) []string {
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
fileAbs := filepath.Join(abs, file.Name())
|
fileAbs := filepath.Join(abs, file.Name())
|
||||||
if file.IsDir() {
|
if file.IsDir() {
|
||||||
paths = append(paths, FilePaths(fileAbs)...)
|
paths = append(paths, Paths(fileAbs)...)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
paths = append(paths, fileAbs)
|
paths = append(paths, fileAbs)
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
func TestFilePaths(t *testing.T) {
|
func TestFilePaths(t *testing.T) {
|
||||||
var line int
|
var line int
|
||||||
var fileCount int
|
var fileCount int
|
||||||
for _, path := range file.FilePaths(`D:\sources\minotaur`) {
|
for _, path := range file.Paths(`D:\sources\minotaur`) {
|
||||||
if !strings.HasSuffix(path, ".go") {
|
if !strings.HasSuffix(path, ".go") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ func ExampleNavMesh_FindPath() {
|
||||||
|
|
||||||
for x := sx; x <= bx; x++ {
|
for x := sx; x <= bx; x++ {
|
||||||
for y := sy; y <= by; y++ {
|
for y := sy; y <= by; y++ {
|
||||||
fp.Put(geometry.NewPoint[int](int(x), int(y)), '+')
|
fp.Put(geometry.NewPoint[int](x, y), '+')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ func (slf *SortMap[K, V]) For(handle func(key K, value V) bool) {
|
||||||
|
|
||||||
func (slf *SortMap[K, V]) ForSort(handle func(key K, value V) bool) {
|
func (slf *SortMap[K, V]) ForSort(handle func(key K, value V) bool) {
|
||||||
var indexes []int
|
var indexes []int
|
||||||
for i, _ := range slf.s {
|
for i := range slf.s {
|
||||||
indexes = append(indexes, i)
|
indexes = append(indexes, i)
|
||||||
}
|
}
|
||||||
sort.Ints(indexes)
|
sort.Ints(indexes)
|
||||||
|
@ -85,7 +85,7 @@ func (slf *SortMap[K, V]) ToSlice() []V {
|
||||||
|
|
||||||
func (slf *SortMap[K, V]) ToSliceSort() []V {
|
func (slf *SortMap[K, V]) ToSliceSort() []V {
|
||||||
var indexes []int
|
var indexes []int
|
||||||
for i, _ := range slf.s {
|
for i := range slf.s {
|
||||||
indexes = append(indexes, i)
|
indexes = append(indexes, i)
|
||||||
}
|
}
|
||||||
sort.Ints(indexes)
|
sort.Ints(indexes)
|
||||||
|
|
|
@ -27,7 +27,7 @@ func Pow(a, n int) int {
|
||||||
if n == 1 {
|
if n == 1 {
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
var result int = 1
|
var result = 1
|
||||||
factor := a
|
factor := a
|
||||||
for n != 0 {
|
for n != 0 {
|
||||||
if n&1 != 0 {
|
if n&1 != 0 {
|
||||||
|
|
|
@ -216,7 +216,7 @@ func (slf *Map[Key, Value]) Keys() []Key {
|
||||||
defer slf.lock.RUnlock()
|
defer slf.lock.RUnlock()
|
||||||
}
|
}
|
||||||
var s = make([]Key, 0, len(slf.data))
|
var s = make([]Key, 0, len(slf.data))
|
||||||
for k, _ := range slf.data {
|
for k := range slf.data {
|
||||||
s = append(s, k)
|
s = append(s, k)
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
|
|
|
@ -183,7 +183,7 @@ func (slf *MapSegment[Key, Value]) RangeFree(handle func(key Key, value Value, s
|
||||||
func (slf *MapSegment[Key, Value]) Keys() []Key {
|
func (slf *MapSegment[Key, Value]) Keys() []Key {
|
||||||
var s = make([]Key, 0, len(slf.cache))
|
var s = make([]Key, 0, len(slf.cache))
|
||||||
slf.lock.RLock()
|
slf.lock.RLock()
|
||||||
for k, _ := range slf.cache {
|
for k := range slf.cache {
|
||||||
s = append(s, k)
|
s = append(s, k)
|
||||||
}
|
}
|
||||||
defer slf.lock.RUnlock()
|
defer slf.lock.RUnlock()
|
||||||
|
|
Loading…
Reference in New Issue