Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var BindingNameAnalyzer = analysis.Analyzer{
Name: "bindingtaglint",
Doc: "report bad usage for validator tag",
Run: runBindingTagLint,
}
View Source
var BsonAnalyzer = analysis.Analyzer{ Name: "bsontaglint", Doc: "report bson tag problem", Run: runTagChecker("bson", func(pass *analysis.Pass, field *ast.Field, tag string) { bsonTag := ParseBsonTag(tag) if bsonTag.Skip { return } if len(bsonTag.InvalidOptions) > 0 { pass.Reportf(field.Tag.Pos(), "invalid bson options:%q", render(pass.Fset, field.Tag)) } if len(field.Names) > 0 && bsonTag.Name == strings.ToLower(field.Names[0].Name) { pass.Reportf(field.Tag.Pos(), "same bson tag name:%q", render(pass.Fset, field.Tag)) } if bsonTag.Inline && !isBsonInlineable(pass.TypesInfo.TypeOf(field.Type)) { pass.Reportf(field.Tag.Pos(), "inline must be struct, pointer to struct, map[string]*:%q", render(pass.Fset, field.Tag)) } if bsonTag.MinSize && !isBsonMinSizeable(pass.TypesInfo.TypeOf(field.Type)) { pass.Reportf(field.Tag.Pos(), "minsize must be int64, uint64, uintptr:%q", render(pass.Fset, field.Tag)) } }), }
View Source
var JsonNameAnalyzer = analysis.Analyzer{ Name: "jsontaglint", Doc: "report unused json tag", Run: runTagChecker("json", func(pass *analysis.Pass, f *ast.Field, tag string) { jsonTag := ParseJsonTag(tag) if jsonTag.Skip { return } if !isValidTag(jsonTag.Name) { pass.Reportf(f.Tag.Pos(), "invalid name:%q", render(pass.Fset, f.Tag)) } if jsonTag.String { if !isStringable(pass.TypesInfo.TypeOf(f.Type)) { pass.Report(analysis.Diagnostic{ Pos: f.Tag.Pos(), End: f.Tag.End(), Message: fmt.Sprintf("string must use on scalar field:%q", render(pass.Fset, f.Tag)), }) } } if len(f.Names) != 0 && jsonTag.Name == f.Names[0].String() { pass.Report(analysis.Diagnostic{ Pos: f.Tag.Pos(), End: f.Tag.End(), Message: fmt.Sprintf("same json tag name %q", render(pass.Fset, f.Tag)), }) } }), }
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.