From b89e5d1a1242d66351b030babad240e3bf582462 Mon Sep 17 00:00:00 2001 From: davyxu Date: Sun, 18 Sep 2022 20:00:03 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4filelist.txt=E7=94=9F?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gen/pbscheme/gen_dir.go | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/gen/pbscheme/gen_dir.go b/gen/pbscheme/gen_dir.go index 683bb3f..39c0303 100644 --- a/gen/pbscheme/gen_dir.go +++ b/gen/pbscheme/gen_dir.go @@ -5,10 +5,8 @@ import ( "github.com/davyxu/protoplus/codegen" "github.com/davyxu/protoplus/gen" "github.com/davyxu/protoplus/model" - "io/ioutil" "path/filepath" "sort" - "strings" ) const protoDirCodeTemplate = `// Generated by github.com/davyxu/protoplus @@ -104,26 +102,26 @@ func GenProtoDir(ctx *gen.Context) error { rootDS := &PBDescriptorSet{DescriptorSet: *ctx.DescriptorSet} - var sb strings.Builder + //var sb strings.Builder var srcNameList []string for srcName, ds := range rootDS.DescriptorSetBySource() { srcNameList = append(srcNameList, srcName) - gen := codegen.NewCodeGen("dirproto"). + generator := codegen.NewCodeGen("dirproto"). RegisterTemplateFunc(codegen.UsefulFunc). RegisterTemplateFunc(UsefulFunc). ParseTemplate(protoDirCodeTemplate, ds) - if gen.Error() != nil { - fmt.Println(string(gen.Data())) - return gen.Error() + if generator.Error() != nil { + fmt.Println(string(generator.Data())) + return generator.Error() } fullPathName := filepath.Join(ctx.OutputFileName, srcName) - err := gen.WriteOutputFile(fullPathName).Error() + err := generator.WriteOutputFile(fullPathName).Error() if err != nil { return err } @@ -131,11 +129,11 @@ func GenProtoDir(ctx *gen.Context) error { sort.Strings(srcNameList) - for _, d := range srcNameList { - fmt.Fprintf(&sb, "%s ", d) - } - - err := ioutil.WriteFile(filepath.Join(ctx.OutputFileName, "filelist.txt"), []byte(sb.String()), 0666) + //for _, d := range srcNameList { + // fmt.Fprintf(&sb, "%s ", d) + //} + // + //err := ioutil.WriteFile(filepath.Join(ctx.OutputFileName, "filelist.txt"), []byte(sb.String()), 0666) - return err + return nil }