MCPcopy Create free account
hub / github.com/google/go-github / processTag

Function processTag

tools/structfield/structfield.go:146–164  ·  view source on GitHub ↗
(structName string, goField *ast.Ident, field *ast.Field, structTag reflect.StructTag, tagType string, pass *analysis.Pass, allowedTagNames, allowedTagTypes map[string]bool)

Source from the content-addressed store, hash-verified

144}
145
146func processTag(structName string, goField *ast.Ident, field *ast.Field, structTag reflect.StructTag, tagType string, pass *analysis.Pass, allowedTagNames, allowedTagTypes map[string]bool) {
147 tagName, ok := structTag.Lookup(tagType)
148 if !ok || tagName == "-" {
149 return
150 }
151
152 hasOmitEmpty := strings.Contains(tagName, ",omitempty")
153 hasOmitZero := strings.Contains(tagName, ",omitzero")
154
155 if hasOmitEmpty || hasOmitZero {
156 checkGoFieldType(structName, goField.Name, tagType, field, field.Pos(), pass, allowedTagTypes, hasOmitEmpty, hasOmitZero)
157 tagName = strings.ReplaceAll(tagName, ",omitzero", "")
158 tagName = strings.ReplaceAll(tagName, ",omitempty", "")
159 }
160 if tagType == "url" {
161 tagName = strings.ReplaceAll(tagName, ",comma", "")
162 }
163 checkGoFieldName(structName, goField.Name, tagType, tagName, goField.Pos(), pass, allowedTagNames)
164}
165
166func checkAndReportInvalidTypesForOmitzero(structName, tagType, goFieldName string, fieldType ast.Expr, tokenPos token.Pos, pass *analysis.Pass) bool {
167 switch ft := fieldType.(type) {

Callers 1

processStructFieldFunction · 0.85

Calls 2

checkGoFieldTypeFunction · 0.85
checkGoFieldNameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…