x/tools/go/analysis: How to report RelatedInformation

36 views Asked by At

I can only get the following results, Even if I set Related like this code

pass.Report(analysis.Diagnostic{
    Pos:     n.Pos(),
    Message: "",
    Related: []analysis.RelatedInformation{{
        Pos:     n.Pos(),
        Message: "related",
    }},
})

mytools -rule_name -json ./...

{
    "package_name": {
        "rule_name": [
            {
                "posn": "main.go:34:2",
                "message": ""
            }
        ]
    }
}

How can I get results like this json

{
    "package_name": {
        "rule_name": [
            {
                "posn": "main.go:34:2",
                "message": "",
                "Related": [
                    {
                        "posn": "main.go:34:2",
                        "message": ""
                    }
                ]
            }
        ]
    }
}
0

There are 0 answers