From 91b28c5dcda3e1c63fc26972c5fa394c4afa708d Mon Sep 17 00:00:00 2001 From: Skyenought Date: Sat, 10 Aug 2024 09:26:50 +0800 Subject: [PATCH] feat: add config_generator for cwgo/pkg --- pkg/config_generator/metadata.go | 6 ------ pkg/config_generator/yaml2go.go | 4 ++-- pkg/config_generator/yaml2go_test.go | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/pkg/config_generator/metadata.go b/pkg/config_generator/metadata.go index 477328d3..13f5333d 100644 --- a/pkg/config_generator/metadata.go +++ b/pkg/config_generator/metadata.go @@ -16,12 +16,6 @@ package config_generator -const ( - Yaml = "yaml" - Json = "json" - Text = "text" -) - type ConfigGenerateMeta struct { Desc string `json:"desc,omitempty"` Kind string `json:"kind,omitempty"` diff --git a/pkg/config_generator/yaml2go.go b/pkg/config_generator/yaml2go.go index 15921bab..f71e1787 100644 --- a/pkg/config_generator/yaml2go.go +++ b/pkg/config_generator/yaml2go.go @@ -26,13 +26,13 @@ import ( ) // New creates Yaml2Go object -func New(key, desc, kind string, fileType ConfigValueType) Yaml2Go { +func New(key, desc, kind string, configValueType ConfigValueType) Yaml2Go { return Yaml2Go{ StructsMeta: &ConfigGenerateMeta{ Key: key, Kind: kind, Desc: desc, - ConfigValueType: fileType, + ConfigValueType: configValueType, structTree: make(map[string]Struct), }, } diff --git a/pkg/config_generator/yaml2go_test.go b/pkg/config_generator/yaml2go_test.go index 113c06ad..53bd163e 100644 --- a/pkg/config_generator/yaml2go_test.go +++ b/pkg/config_generator/yaml2go_test.go @@ -32,7 +32,7 @@ kitex: ` func TestYaml2Go(t *testing.T) { - yaml2Go := New("key", "desc", "group", "YamlType") + yaml2Go := New("key", "desc", "group", ConfigValueType_YamlType) s, err := yaml2Go.Convert("config", []byte(value)) if err != nil { t.Fatal(err)