configexport

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package configexport 提供了XLSX配置转换为JSON及Go代码的导表工具实现

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigExport

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

func Merge added in v0.0.4

func Merge(exports ...*ConfigExport) *ConfigExport

Merge 合并多个导表配置

func New

func New(xlsxPath string) *ConfigExport

New 创建一个导表配置

Example
package main

import (
	"fmt"
	"github.com/kercylan98/minotaur/config"
	"github.com/kercylan98/minotaur/planner/configexport"
	"github.com/kercylan98/minotaur/planner/configexport/example"
	"os"
	"path/filepath"
	"strings"
)

func main() {
	var workdir = "./"
	files, err := os.ReadDir(workdir)
	if err != nil {
		panic(err)
	}
	var ces []*configexport.ConfigExport
	for _, file := range files {
		if file.IsDir() || !strings.HasSuffix(file.Name(), ".xlsx") || strings.HasPrefix(file.Name(), "~") {
			continue
		}

		ces = append(ces, configexport.New(filepath.Join(workdir, file.Name())))
	}

	c := configexport.Merge(ces...)
	outDir := filepath.Join(workdir, "example")
	c.ExportGo("", outDir)
	c.ExportServer("", outDir)
	c.ExportClient("", outDir)

	// 下方为配置加载代码
	// 使用生成的 LoadConfig 函数加载配置
	config.Init(outDir, example.LoadConfig, example.Refresh)

	fmt.Println("success")

}
Output:

success

func (*ConfigExport) ExportClient

func (slf *ConfigExport) ExportClient(prefix, outputDir string)

func (*ConfigExport) ExportGo

func (slf *ConfigExport) ExportGo(prefix, outputDir string)

func (*ConfigExport) ExportServer

func (slf *ConfigExport) ExportServer(prefix, outputDir string)

Directories

Path Synopsis
Code generated by minotaur-config-export.
Code generated by minotaur-config-export.

Jump to

Keyboard shortcuts

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