MCPcopy Index your code
hub / github.com/google/go-github / run

Function run

tools/structfield/structfield.go:102–135  ·  view source on GitHub ↗
(pass *analysis.Pass, allowedTagNames, allowedTagTypes map[string]bool)

Source from the content-addressed store, hash-verified

100}
101
102func run(pass *analysis.Pass, allowedTagNames, allowedTagTypes map[string]bool) (any, error) {
103 for _, file := range pass.Files {
104 ast.Inspect(file, func(n ast.Node) bool {
105 if n == nil {
106 return false
107 }
108
109 t, ok := n.(*ast.TypeSpec)
110 if !ok {
111 return true
112 }
113 structType, ok := t.Type.(*ast.StructType)
114 if !ok {
115 return true
116 }
117
118 // Check only exported
119 if !ast.IsExported(t.Name.Name) {
120 return true
121 }
122
123 for _, field := range structType.Fields.List {
124 if field.Tag == nil || len(field.Names) == 0 {
125 continue
126 }
127
128 processStructField(t.Name.Name, field, pass, allowedTagNames, allowedTagTypes)
129 }
130
131 return true
132 })
133 }
134 return nil, nil
135}
136
137func processStructField(structName string, field *ast.Field, pass *analysis.Pass, allowedTagNames, allowedTagTypes map[string]bool) {
138 goField := field.Names[0]

Callers 1

BuildAnalyzersMethod · 0.70

Calls 1

processStructFieldFunction · 0.85

Tested by

no test coverage detected