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 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)
Click to show internal directories.
Click to hide internal directories.