Skip to content

Commit 33a11e8

Browse files
refactor:
- 去掉多余的收集导包信息逻辑 - 测试例子文件调整
1 parent d7fc593 commit 33a11e8

File tree

3 files changed

+1
-16
lines changed

3 files changed

+1
-16
lines changed
File renamed without changes.

example/opt_example_gen.go renamed to example/opt_user_gen.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
package example
66

7-
import (
8-
"github.com/chenmingyong0423/go-optioner/example/third_party"
9-
)
7+
import "github.com/chenmingyong0423/go-optioner/example/third_party"
108

119
type UserOption func(*User)
1210

options/options_generator.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"log"
2929
"os"
3030
"reflect"
31-
"strconv"
3231
"strings"
3332
)
3433

@@ -154,8 +153,6 @@ func (g *Generator) parseStruct(fileName string) bool {
154153
}
155154
log.Printf("Generating Struct Field \"%s\" of type \"%s\"\n", fieldName, fieldType)
156155
}
157-
// 收集 package 信息
158-
g.CollectImports(file)
159156
return true
160157
} else {
161158
log.Fatal(fmt.Sprintf("Target[%s] type is not a struct", g.StructInfo.StructName))
@@ -269,13 +266,3 @@ func (g *Generator) parseFuncType(f *ast.FuncType) string {
269266
}
270267
return fmt.Sprintf("func(%s) (%s)", strings.Join(params, ", "), strings.Join(results, ", "))
271268
}
272-
273-
func (g *Generator) CollectImports(file *ast.File) {
274-
for _, imp := range file.Imports {
275-
path, err := strconv.Unquote(imp.Path.Value)
276-
if err != nil {
277-
log.Fatalf("Failed to unquote import path: %v", err)
278-
}
279-
g.StructInfo.Imports = append(g.StructInfo.Imports, path)
280-
}
281-
}

0 commit comments

Comments
 (0)