Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: Printf wrappers not checked when implemented in a different package than caller #53131

Closed
amurzeau opened this issue May 28, 2022 · 3 comments
Assignees
Labels
FrozenDueToAge gopls/analysis Issues related to running analysis in gopls gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@amurzeau
Copy link

gopls version

Build info
----------
golang.org/x/tools/gopls v0.8.4
    golang.org/x/tools/gopls@v0.8.4 h1:zGZsAXAb0LLws/Z+2BCWR17dkPHhIO2GYwYSSkeXX5c=
    github.com/BurntSushi/toml@v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU=
    github.com/google/go-cmp@v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/exp/typeparams@v0.0.0-20220218215828-6cf2b201936e h1:qyrTQ++p1afMkO4DPEeLGq/3oTsdlvdH4vqZUBWzUKM=
    golang.org/x/mod@v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
    golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
    golang.org/x/sys@v0.0.0-20220209214540-3681064d5158 h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c=
    golang.org/x/text@v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
    golang.org/x/tools@v0.1.11-0.20220513164230-dfee1649af67 h1:CJwk4qG1fov4WP7/DWhhb7OQVZlQKAl1rEMnDF+ceGU=
    golang.org/x/vuln@v0.0.0-20220503210553-a5481fb0c8be h1:jokAF1mfylAi1iTQx7C44B7vyXUcSEMw8eDv0PzNu8s=
    honnef.co/go/tools@v0.3.0 h1:2LdYUZ7CIxnYgskbUZfY7FPggmqnh6shBqfWa8Tn3XU=
    mvdan.cc/gofumpt@v0.3.0 h1:kTojdZo9AcEYbQYhGuLf/zszYthRdhDNDUi2JKTxas4=
    mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
go: go1.18.2

go env

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/doc/.cache/go-build"
GOENV="/home/doc/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/doc/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/doc/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.18"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.18/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.2"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/doc/src/go-test-analyzer-printf/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3422587632=/tmp/go-build -gno-record-gcc-switches"

What did you do?

While using VSCode with gopls, I found that Printf wrappers are not checked when the Printf wrapper is in a different package than the code that calls it.

What did you expect to see?

I'm expecting that Printf wrappers to be checked even if they are implemented in a different go package.

What did you see instead?

image
(https://go.dev/play/p/9GMssNuK7rZ)

In the image, in main.go file:

  • log.Printf (the go's log package) is properly checked (a diagnostic is reported for a missing argument to match the %s)
  • logWrapper.Debugf is not checked and I expect it to be checked given it calls log.Printf (the same way logWrapper.Testf is checked)

I'm expecting to have a printf diagnostic for the line main.go:11 too.

Editor and settings

I'm using default settings in VS Code.

VS Code version 1.67.1
vscode-go plugin version v0.33.1

Logs

Language server logs:

[Trace - 22:56:25] Sending request 'textDocument/codeAction - (35)'.
Params: {
    "textDocument": {
        "uri": "file:///home/doc/src/go-test-analyzer-printf/main.go"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 0,
            "character": 0
        }
    },
    "context": {
        "diagnostics": []
    }
}


[Trace - 22:56:25] Received response 'textDocument/codeAction - (35)' in 42ms.
No result returned.


[Trace - 22:56:25] Sending request 'textDocument/documentLink - (36)'.
Params: {
    "textDocument": {
        "uri": "file:///home/doc/src/go-test-analyzer-printf/main.go"
    }
}


[Trace - 22:56:25] Received response 'textDocument/documentLink - (36)' in 3ms.
Result: [
    {
        "range": {
            "start": {
                "line": 3,
                "character": 2
            },
            "end": {
                "line": 3,
                "character": 5
            }
        },
        "target": "https://pkg.go.dev/log?utm_source=gopls"
    },
    {
        "range": {
            "start": {
                "line": 5,
                "character": 2
            },
            "end": {
                "line": 5,
                "character": 56
            }
        },
        "target": "https://pkg.go.dev/github.com/amurzeau/go-test-analyzer-printf/logWrapper?utm_source=gopls"
    }
]


[Trace - 22:56:25] Sending request 'textDocument/codeAction - (37)'.
Params: {
    "textDocument": {
        "uri": "file:///home/doc/src/go-test-analyzer-printf/main.go"
    },
    "range": {
        "start": {
            "line": 12,
            "character": 1
        },
        "end": {
            "line": 12,
            "character": 1
        }
    },
    "context": {
        "diagnostics": []
    }
}


[Trace - 22:56:25] Received response 'textDocument/codeAction - (37)' in 2ms.
No result returned.


[Trace - 22:56:25] Sending request 'textDocument/codeLens - (38)'.
Params: {
    "textDocument": {
        "uri": "file:///home/doc/src/go-test-analyzer-printf/main.go"
    }
}


[Trace - 22:56:25] Received response 'textDocument/codeLens - (38)' in 1ms.
No result returned.


[Trace - 22:56:25] Sending request 'textDocument/foldingRange - (39)'.
Params: {
    "textDocument": {
        "uri": "file:///home/doc/src/go-test-analyzer-printf/main.go"
    }
}


[Trace - 22:56:25] Received response 'textDocument/foldingRange - (39)' in 1ms.
Result: [
    {
        "startLine": 2,
        "startCharacter": 8,
        "endLine": 5,
        "endCharacter": 57,
        "kind": "imports"
    },
    {
        "startLine": 8,
        "startCharacter": 13,
        "endLine": 11,
        "endCharacter": 19
    }
]


[Trace - 22:56:35] Sending request 'shutdown - (40)'.
[Trace - 22:56:35] Received response 'shutdown - (40)' in 1ms.
No result returned.


[Trace - 22:56:35] Sending notification 'exit'.
No parameters provided.


[Trace - 22:56:35] Sending request 'initialize - (0)'.
Params: {
    "processId": 44457,
    "clientInfo": {
        "name": "Visual Studio Code",
        "version": "1.67.1"
    },
    "locale": "en",
    "rootPath": "/home/doc/src/go-test-analyzer-printf",
    "rootUri": "file:///home/doc/src/go-test-analyzer-printf",
    "capabilities": {
        "workspace": {
            "applyEdit": true,
            "workspaceEdit": {
                "documentChanges": true,
                "resourceOperations": [
                    "create",
                    "rename",
                    "delete"
                ],
                "failureHandling": "textOnlyTransactional",
                "normalizesLineEndings": true,
                "changeAnnotationSupport": {
                    "groupsOnLabel": true
                }
            },
            "didChangeConfiguration": {
                "dynamicRegistration": true
            },
            "didChangeWatchedFiles": {
                "dynamicRegistration": true
            },
            "symbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26
                    ]
                },
                "tagSupport": {
                    "valueSet": [
                        1
                    ]
                }
            },
            "codeLens": {
                "refreshSupport": true
            },
            "executeCommand": {
                "dynamicRegistration": true
            },
            "configuration": true,
            "workspaceFolders": true,
            "semanticTokens": {
                "refreshSupport": true
            },
            "fileOperations": {
                "dynamicRegistration": true,
                "didCreate": true,
                "didRename": true,
                "didDelete": true,
                "willCreate": true,
                "willRename": true,
                "willDelete": true
            }
        },
        "textDocument": {
            "publishDiagnostics": {
                "relatedInformation": true,
                "versionSupport": false,
                "tagSupport": {
                    "valueSet": [
                        1,
                        2
                    ]
                },
                "codeDescriptionSupport": true,
                "dataSupport": true
            },
            "synchronization": {
                "dynamicRegistration": true,
                "willSave": true,
                "willSaveWaitUntil": true,
                "didSave": true
            },
            "completion": {
                "dynamicRegistration": true,
                "contextSupport": true,
                "completionItem": {
                    "snippetSupport": true,
                    "commitCharactersSupport": true,
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ],
                    "deprecatedSupport": true,
                    "preselectSupport": true,
                    "tagSupport": {
                        "valueSet": [
                            1
                        ]
                    },
                    "insertReplaceSupport": true,
                    "resolveSupport": {
                        "properties": [
                            "documentation",
                            "detail",
                            "additionalTextEdits"
                        ]
                    },
                    "insertTextModeSupport": {
                        "valueSet": [
                            1,
                            2
                        ]
                    }
                },
                "completionItemKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25
                    ]
                }
            },
            "hover": {
                "dynamicRegistration": true,
                "contentFormat": [
                    "markdown",
                    "plaintext"
                ]
            },
            "signatureHelp": {
                "dynamicRegistration": true,
                "signatureInformation": {
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ],
                    "parameterInformation": {
                        "labelOffsetSupport": true
                    },
                    "activeParameterSupport": true
                },
                "contextSupport": true
            },
            "definition": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "references": {
                "dynamicRegistration": true
            },
            "documentHighlight": {
                "dynamicRegistration": true
            },
            "documentSymbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26
                    ]
                },
                "hierarchicalDocumentSymbolSupport": true,
                "tagSupport": {
                    "valueSet": [
                        1
                    ]
                },
                "labelSupport": true
            },
            "codeAction": {
                "dynamicRegistration": true,
                "isPreferredSupport": true,
                "disabledSupport": true,
                "dataSupport": true,
                "resolveSupport": {
                    "properties": [
                        "edit"
                    ]
                },
                "codeActionLiteralSupport": {
                    "codeActionKind": {
                        "valueSet": [
                            "",
                            "quickfix",
                            "refactor",
                            "refactor.extract",
                            "refactor.inline",
                            "refactor.rewrite",
                            "source",
                            "source.organizeImports"
                        ]
                    }
                },
                "honorsChangeAnnotations": false
            },
            "codeLens": {
                "dynamicRegistration": true
            },
            "formatting": {
                "dynamicRegistration": true
            },
            "rangeFormatting": {
                "dynamicRegistration": true
            },
            "onTypeFormatting": {
                "dynamicRegistration": true
            },
            "rename": {
                "dynamicRegistration": true,
                "prepareSupport": true,
                "prepareSupportDefaultBehavior": 1,
                "honorsChangeAnnotations": true
            },
            "documentLink": {
                "dynamicRegistration": true,
                "tooltipSupport": true
            },
            "typeDefinition": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "implementation": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "colorProvider": {
                "dynamicRegistration": true
            },
            "foldingRange": {
                "dynamicRegistration": true,
                "rangeLimit": 5000,
                "lineFoldingOnly": true
            },
            "declaration": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "selectionRange": {
                "dynamicRegistration": true
            },
            "callHierarchy": {
                "dynamicRegistration": true
            },
            "semanticTokens": {
                "dynamicRegistration": true,
                "tokenTypes": [
                    "namespace",
                    "type",
                    "class",
                    "enum",
                    "interface",
                    "struct",
                    "typeParameter",
                    "parameter",
                    "variable",
                    "property",
                    "enumMember",
                    "event",
                    "function",
                    "method",
                    "macro",
                    "keyword",
                    "modifier",
                    "comment",
                    "string",
                    "number",
                    "regexp",
                    "operator"
                ],
                "tokenModifiers": [
                    "declaration",
                    "definition",
                    "readonly",
                    "static",
                    "deprecated",
                    "abstract",
                    "async",
                    "modification",
                    "documentation",
                    "defaultLibrary"
                ],
                "formats": [
                    "relative"
                ],
                "requests": {
                    "range": true,
                    "full": {
                        "delta": true
                    }
                },
                "multilineTokenSupport": false,
                "overlappingTokenSupport": false
            },
            "linkedEditingRange": {
                "dynamicRegistration": true
            }
        },
        "window": {
            "showMessage": {
                "messageActionItem": {
                    "additionalPropertiesSupport": true
                }
            },
            "showDocument": {
                "support": true
            },
            "workDoneProgress": true
        },
        "general": {
            "regularExpressions": {
                "engine": "ECMAScript",
                "version": "ES2020"
            },
            "markdown": {
                "parser": "marked",
                "version": "1.1.0"
            }
        }
    },
    "initializationOptions": {},
    "trace": "verbose",
    "workspaceFolders": [
        {
            "uri": "file:///home/doc/src/go-test-analyzer-printf",
            "name": "go-test-analyzer-printf"
        }
    ]
}


[Trace - 22:56:35] Received response 'initialize - (0)' in 67ms.
Result: {
    "capabilities": {
        "textDocumentSync": {
            "openClose": true,
            "change": 2,
            "save": {}
        },
        "completionProvider": {
            "triggerCharacters": [
                "."
            ],
            "completionItem": {}
        },
        "hoverProvider": true,
        "signatureHelpProvider": {
            "triggerCharacters": [
                "(",
                ","
            ]
        },
        "definitionProvider": true,
        "typeDefinitionProvider": true,
        "implementationProvider": true,
        "referencesProvider": true,
        "documentHighlightProvider": true,
        "documentSymbolProvider": true,
        "codeActionProvider": {
            "codeActionKinds": [
                "quickfix",
                "refactor.extract",
                "refactor.rewrite",
                "source.fixAll",
                "source.organizeImports"
            ]
        },
        "codeLensProvider": {},
        "documentLinkProvider": {},
        "workspaceSymbolProvider": true,
        "documentFormattingProvider": true,
        "documentOnTypeFormattingProvider": {
            "firstTriggerCharacter": ""
        },
        "renameProvider": {
            "prepareProvider": true
        },
        "foldingRangeProvider": true,
        "executeCommandProvider": {
            "commands": [
                "gopls.add_dependency",
                "gopls.add_import",
                "gopls.apply_fix",
                "gopls.check_upgrades",
                "gopls.edit_go_directive",
                "gopls.gc_details",
                "gopls.generate",
                "gopls.generate_gopls_mod",
                "gopls.go_get_package",
                "gopls.list_imports",
                "gopls.list_known_packages",
                "gopls.regenerate_cgo",
                "gopls.remove_dependency",
                "gopls.run_tests",
                "gopls.run_vulncheck_exp",
                "gopls.start_debugging",
                "gopls.test",
                "gopls.tidy",
                "gopls.toggle_gc_details",
                "gopls.update_go_sum",
                "gopls.upgrade_dependency",
                "gopls.vendor"
            ]
        },
        "callHierarchyProvider": true,
        "workspace": {
            "workspaceFolders": {
                "supported": true,
                "changeNotifications": "workspace/didChangeWorkspaceFolders"
            }
        }
    },
    "serverInfo": {
        "name": "gopls",
        "version": "{\"GoVersion\":\"go1.18.2\",\"Path\":\"golang.org/x/tools/gopls\",\"Main\":{\"Path\":\"golang.org/x/tools/gopls\",\"Version\":\"v0.8.4\",\"Sum\":\"h1:zGZsAXAb0LLws/Z+2BCWR17dkPHhIO2GYwYSSkeXX5c=\",\"Replace\":null},\"Deps\":[{\"Path\":\"github.com/BurntSushi/toml\",\"Version\":\"v1.0.0\",\"Sum\":\"h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU=\",\"Replace\":null},{\"Path\":\"github.com/google/go-cmp\",\"Version\":\"v0.5.7\",\"Sum\":\"h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=\",\"Replace\":null},{\"Path\":\"github.com/sergi/go-diff\",\"Version\":\"v1.1.0\",\"Sum\":\"h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=\",\"Replace\":null},{\"Path\":\"golang.org/x/exp/typeparams\",\"Version\":\"v0.0.0-20220218215828-6cf2b201936e\",\"Sum\":\"h1:qyrTQ++p1afMkO4DPEeLGq/3oTsdlvdH4vqZUBWzUKM=\",\"Replace\":null},{\"Path\":\"golang.org/x/mod\",\"Version\":\"v0.6.0-dev.0.20220419223038-86c51ed26bb4\",\"Sum\":\"h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=\",\"Replace\":null},{\"Path\":\"golang.org/x/sync\",\"Version\":\"v0.0.0-20210220032951-036812b2e83c\",\"Sum\":\"h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=\",\"Replace\":null},{\"Path\":\"golang.org/x/sys\",\"Version\":\"v0.0.0-20220209214540-3681064d5158\",\"Sum\":\"h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c=\",\"Replace\":null},{\"Path\":\"golang.org/x/text\",\"Version\":\"v0.3.7\",\"Sum\":\"h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=\",\"Replace\":null},{\"Path\":\"golang.org/x/tools\",\"Version\":\"v0.1.11-0.20220513164230-dfee1649af67\",\"Sum\":\"h1:CJwk4qG1fov4WP7/DWhhb7OQVZlQKAl1rEMnDF+ceGU=\",\"Replace\":null},{\"Path\":\"golang.org/x/vuln\",\"Version\":\"v0.0.0-20220503210553-a5481fb0c8be\",\"Sum\":\"h1:jokAF1mfylAi1iTQx7C44B7vyXUcSEMw8eDv0PzNu8s=\",\"Replace\":null},{\"Path\":\"honnef.co/go/tools\",\"Version\":\"v0.3.0\",\"Sum\":\"h1:2LdYUZ7CIxnYgskbUZfY7FPggmqnh6shBqfWa8Tn3XU=\",\"Replace\":null},{\"Path\":\"mvdan.cc/gofumpt\",\"Version\":\"v0.3.0\",\"Sum\":\"h1:kTojdZo9AcEYbQYhGuLf/zszYthRdhDNDUi2JKTxas4=\",\"Replace\":null},{\"Path\":\"mvdan.cc/xurls/v2\",\"Version\":\"v2.4.0\",\"Sum\":\"h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=\",\"Replace\":null}],\"Settings\":[{\"Key\":\"-compiler\",\"Value\":\"gc\"},{\"Key\":\"CGO_ENABLED\",\"Value\":\"1\"},{\"Key\":\"CGO_CFLAGS\",\"Value\":\"\"},{\"Key\":\"CGO_CPPFLAGS\",\"Value\":\"\"},{\"Key\":\"CGO_CXXFLAGS\",\"Value\":\"\"},{\"Key\":\"CGO_LDFLAGS\",\"Value\":\"\"},{\"Key\":\"GOARCH\",\"Value\":\"amd64\"},{\"Key\":\"GOOS\",\"Value\":\"linux\"},{\"Key\":\"GOAMD64\",\"Value\":\"v1\"}],\"Version\":\"v0.8.4\"}"
    }
}


[Trace - 22:56:35] Sending notification 'initialized'.
Params: {}


[Trace - 22:56:35] Sending notification 'textDocument/didOpen'.
Params: {
    "textDocument": {
        "uri": "file:///home/doc/src/go-test-analyzer-printf/main.go",
        "languageId": "go",
        "version": 1,
        "text": "package main\n\nimport (\n\t\"log\"\n\n\t\"github.com/amurzeau/go-test-analyzer-printf/logWrapper\"\n)\n\nfunc main() {\n\tlog.Printf(\"%s\")\n\tlogWrapper.Debugf(\"%s\")\n\tlogWrapper.Testf()\n}\n"
    }
}


[Trace - 22:56:35] Sending notification 'textDocument/didOpen'.
Params: {
    "textDocument": {
        "uri": "file:///home/doc/src/go-test-analyzer-printf/logWrapper/log.go",
        "languageId": "go",
        "version": 1,
        "text": "package logWrapper\n\nimport \"log\"\n\nfunc Debugf(format string, v ...any) {\n\tlog.Printf(format, v...)\n}\n\nfunc Testf() {\n\tDebugf(\"%s\")\n}\n"
    }
}


[Trace - 22:56:35] Received request 'window/workDoneProgress/create - (1)'.
Params: {
    "token": "5577006791947779410"
}


[Trace - 22:56:35] Sending response 'window/workDoneProgress/create - (1)'. Processing request took 0ms
No result returned.


[Trace - 22:56:35] Received notification '$/progress'.
Params: {
    "token": "5577006791947779410",
    "value": {
        "kind": "begin",
        "title": "Setting up workspace",
        "message": "Loading packages..."
    }
}


[Trace - 22:56:35] Received request 'workspace/configuration - (2)'.
Params: {
    "items": [
        {
            "scopeUri": "file:///home/doc/src/go-test-analyzer-printf",
            "section": "gopls"
        }
    ]
}


[Trace - 22:56:35] Sending response 'workspace/configuration - (2)'. Processing request took 2ms
Result: [
    {}
]


[Trace - 22:56:35] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "2022/05/28 22:56:35 go env for /home/doc/src/go-test-analyzer-printf\n(root /home/doc/src/go-test-analyzer-printf)\n(go version go version go1.18.2 linux/amd64)\n(valid build configuration = true)\n(build flags: [])\nGOPROXY=https://proxy.golang.org,direct\nGONOSUMDB=\nGO111MODULE=\nGOWORK=\nGOPRIVATE=\nGOROOT=/usr/lib/go-1.18\nGOMOD=/home/doc/src/go-test-analyzer-printf/go.mod\nGONOPROXY=\nGOSUMDB=sum.golang.org\nGOCACHE=/home/doc/.cache/go-build\nGOMODCACHE=/home/doc/go/pkg/mod\nGOFLAGS=\nGOPATH=/home/doc/go\nGOINSECURE=\n\n"
}


[Trace - 22:56:35] Sending request 'textDocument/documentSymbol - (1)'.
Params: {
    "textDocument": {
        "uri": "file:///home/doc/src/go-test-analyzer-printf/logWrapper/log.go"
    }
}


[Trace - 22:56:35] Sending request 'textDocument/documentSymbol - (2)'.
Params: {
    "textDocument": {
        "uri": "file:///home/doc/src/go-test-analyzer-printf/main.go"
    }
}


[Trace - 22:56:35] Sending request 'textDocument/codeAction - (3)'.
Params: {
    "textDocument": {
        "uri": "file:///home/doc/src/go-test-analyzer-printf/main.go"
    },
    "range": {
        "start": {
            "line": 12,
            "character": 1
        },
        "end": {
            "line": 12,
            "character": 1
        }
    },
    "context": {
        "diagnostics": []
    }
}


[Trace - 22:56:35] Sending request 'textDocument/documentLink - (4)'.
Params: {
    "textDocument": {
        "uri": "file:///home/doc/src/go-test-analyzer-printf/main.go"
    }
}


[Trace - 22:56:35] Sending request 'textDocument/documentLink - (5)'.
Params: {
    "textDocument": {
        "uri": "file:///home/doc/src/go-test-analyzer-printf/logWrapper/log.go"
    }
}


[Trace - 22:56:35] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "2022/05/28 22:56:35 go/packages.Load\n\tsnapshot=0\n\tdirectory=/home/doc/src/go-test-analyzer-printf\n\tquery=[builtin github.com/amurzeau/go-test-analyzer-printf/...]\n\tpackages=3\n"
}


[Trace - 22:56:36] Received notification '$/progress'.
Params: {
    "token": "5577006791947779410",
    "value": {
        "kind": "end",
        "message": "Finished loading packages."
    }
}


[Trace - 22:56:36] Received request 'client/registerCapability - (3)'.
Params: {
    "registrations": [
        {
            "id": "workspace/didChangeWatchedFiles-0",
            "method": "workspace/didChangeWatchedFiles",
            "registerOptions": {
                "watchers": [
                    {
                        "globPattern": "{/home/doc/src/go-test-analyzer-printf/logWrapper}",
                        "kind": 7
                    },
                    {
                        "globPattern": "**/*.{go,mod,sum,work}",
                        "kind": 7
                    }
                ]
            }
        }
    ]
}


[Trace - 22:56:36] Sending response 'client/registerCapability - (3)'. Processing request took 2ms
No result returned.


[Trace - 22:56:36] Received request 'client/registerCapability - (4)'.
Params: {
    "registrations": [
        {
            "id": "workspace/didChangeConfiguration",
            "method": "workspace/didChangeConfiguration"
        }
    ]
}


[Trace - 22:56:36] Sending response 'client/registerCapability - (4)'. Processing request took 0ms
No result returned.


[Trace - 22:56:36] Sending request 'textDocument/codeLens - (6)'.
Params: {
    "textDocument": {
        "uri": "file:///home/doc/src/go-test-analyzer-printf/main.go"
    }
}


[Trace - 22:56:36] Sending request 'textDocument/codeLens - (7)'.
Params: {
    "textDocument": {
        "uri": "file:///home/doc/src/go-test-analyzer-printf/logWrapper/log.go"
    }
}


[Trace - 22:56:36] Sending request 'textDocument/foldingRange - (8)'.
Params: {
    "textDocument": {
        "uri": "file:///home/doc/src/go-test-analyzer-printf/main.go"
    }
}


[Trace - 22:56:36] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "2022/05/28 22:56:36 falling back to safe trimming due to type errors: [/usr/lib/go-1.18/src/runtime/vdso_linux.go:53:38: invalid operation: division by zero /usr/lib/go-1.18/src/runtime/vdso_linux.go:54:38: invalid operation: division by zero] or still-missing identifiers: map[memRecordCycle:true pageBits:true]\n\tpackage=\"runtime\"\n"
}


[Trace - 22:56:36] Sending request 'textDocument/foldingRange - (9)'.
Params: {
    "textDocument": {
        "uri": "file:///home/doc/src/go-test-analyzer-printf/logWrapper/log.go"
    }
}


[Trace - 22:56:36] Received response 'textDocument/documentSymbol - (1)' in 684ms.
Result: [
    {
        "name": "Debugf",
        "detail": "(format string, v []any)",
        "kind": 12,
        "range": {
            "start": {
                "line": 4,
                "character": 0
            },
            "end": {
                "line": 6,
                "character": 1
            }
        },
        "selectionRange": {
            "start": {
                "line": 4,
                "character": 5
            },
            "end": {
                "line": 4,
                "character": 11
            }
        }
    },
    {
        "name": "Testf",
        "detail": "()",
        "kind": 12,
        "range": {
            "start": {
                "line": 8,
                "character": 0
            },
            "end": {
                "line": 10,
                "character": 1
            }
        },
        "selectionRange": {
            "start": {
                "line": 8,
                "character": 5
            },
            "end": {
                "line": 8,
                "character": 10
            }
        }
    }
]


[Trace - 22:56:36] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///home/doc/src/go-test-analyzer-printf/logWrapper/log.go",
    "version": 1,
    "diagnostics": [
        {
            "range": {
                "start": {
                    "line": 9,
                    "character": 1
                },
                "end": {
                    "line": 9,
                    "character": 13
                }
            },
            "severity": 2,
            "source": "printf",
            "message": "github.com/amurzeau/go-test-analyzer-printf/logWrapper.Debugf format %s reads arg #1, but call has 0 args"
        }
    ]
}


[Trace - 22:56:36] Received response 'textDocument/documentSymbol - (2)' in 688ms.
Result: [
    {
        "name": "main",
        "detail": "()",
        "kind": 12,
        "range": {
            "start": {
                "line": 8,
                "character": 0
            },
            "end": {
                "line": 12,
                "character": 1
            }
        },
        "selectionRange": {
            "start": {
                "line": 8,
                "character": 5
            },
            "end": {
                "line": 8,
                "character": 9
            }
        }
    }
]


[Trace - 22:56:36] Received response 'textDocument/codeAction - (3)' in 694ms.
No result returned.


[Trace - 22:56:36] Received response 'textDocument/documentLink - (4)' in 672ms.
Result: [
    {
        "range": {
            "start": {
                "line": 3,
                "character": 2
            },
            "end": {
                "line": 3,
                "character": 5
            }
        },
        "target": "https://pkg.go.dev/log?utm_source=gopls"
    },
    {
        "range": {
            "start": {
                "line": 5,
                "character": 2
            },
            "end": {
                "line": 5,
                "character": 56
            }
        },
        "target": "https://pkg.go.dev/github.com/amurzeau/go-test-analyzer-printf/logWrapper?utm_source=gopls"
    }
]


[Trace - 22:56:36] Received response 'textDocument/documentLink - (5)' in 672ms.
Result: [
    {
        "range": {
            "start": {
                "line": 2,
                "character": 8
            },
            "end": {
                "line": 2,
                "character": 11
            }
        },
        "target": "https://pkg.go.dev/log?utm_source=gopls"
    }
]


[Trace - 22:56:36] Received response 'textDocument/codeLens - (6)' in 461ms.
No result returned.


[Trace - 22:56:36] Received response 'textDocument/codeLens - (7)' in 460ms.
No result returned.


[Trace - 22:56:36] Received response 'textDocument/foldingRange - (8)' in 405ms.
Result: [
    {
        "startLine": 2,
        "startCharacter": 8,
        "endLine": 5,
        "endCharacter": 57,
        "kind": "imports"
    },
    {
        "startLine": 8,
        "startCharacter": 13,
        "endLine": 11,
        "endCharacter": 19
    }
]


[Trace - 22:56:36] Received response 'textDocument/foldingRange - (9)' in 121ms.
Result: [
    {
        "startLine": 4,
        "startCharacter": 38,
        "endLine": 5,
        "endCharacter": 25
    },
    {
        "startLine": 8,
        "startCharacter": 14,
        "endLine": 9,
        "endCharacter": 13
    }
]


[Trace - 22:56:36] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///home/doc/src/go-test-analyzer-printf/main.go",
    "version": 1,
    "diagnostics": [
        {
            "range": {
                "start": {
                    "line": 9,
                    "character": 1
                },
                "end": {
                    "line": 9,
                    "character": 17
                }
            },
            "severity": 2,
            "source": "printf",
            "message": "log.Printf format %s reads arg #1, but call has 0 args"
        }
    ]
}


[Trace - 22:56:37] Sending request 'textDocument/codeAction - (10)'.
Params: {
    "textDocument": {
        "uri": "file:///home/doc/src/go-test-analyzer-printf/main.go"
    },
    "range": {
        "start": {
            "line": 12,
            "character": 1
        },
        "end": {
            "line": 12,
            "character": 1
        }
    },
    "context": {
        "diagnostics": []
    }
}


[Trace - 22:56:37] Received response 'textDocument/codeAction - (10)' in 5ms.
No result returned.

gopls logs:

[Info  - 22:56:35] 2022/05/28 22:56:35 go env for /home/doc/src/go-test-analyzer-printf
(root /home/doc/src/go-test-analyzer-printf)
(go version go version go1.18.2 linux/amd64)
(valid build configuration = true)
(build flags: [])
GOPROXY=https://proxy.golang.org,direct
GONOSUMDB=
GO111MODULE=
GOWORK=
GOPRIVATE=
GOROOT=/usr/lib/go-1.18
GOMOD=/home/doc/src/go-test-analyzer-printf/go.mod
GONOPROXY=
GOSUMDB=sum.golang.org
GOCACHE=/home/doc/.cache/go-build
GOMODCACHE=/home/doc/go/pkg/mod
GOFLAGS=
GOPATH=/home/doc/go
GOINSECURE=


[Info  - 22:56:35] 2022/05/28 22:56:35 go/packages.Load
	snapshot=0
	directory=/home/doc/src/go-test-analyzer-printf
	query=[builtin github.com/amurzeau/go-test-analyzer-printf/...]
	packages=3

[Info  - 22:56:36] 2022/05/28 22:56:36 falling back to safe trimming due to type errors: [/usr/lib/go-1.18/src/runtime/vdso_linux.go:53:38: invalid operation: division by zero /usr/lib/go-1.18/src/runtime/vdso_linux.go:54:38: invalid operation: division by zero] or still-missing identifiers: map[memRecordCycle:true pageBits:true]
	package="runtime"

[Info  - 22:57:06] 2022/05/28 22:57:06 background imports cache refresh starting

[Info  - 22:57:06] 2022/05/28 22:57:06 background refresh finished after 151.678818ms
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels May 28, 2022
@gopherbot gopherbot added this to the Unreleased milestone May 28, 2022
@amurzeau amurzeau changed the title x/tools/gopls: x/tools/gopls: Printf wrappers not checked when implemented in a different package than caller May 28, 2022
@findleyr
Copy link
Contributor

At first I thought this was a duplicate of #48738, but in this case your logWrapper is inside the workspace, and so this should work (log.Printf should be recognized as a print function, even if we don't analyze its function body).

@findleyr findleyr added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 31, 2022
@jamalc jamalc modified the milestones: Unreleased, gopls/later Jun 6, 2022
@findleyr findleyr added the gopls/analysis Issues related to running analysis in gopls label Jun 7, 2022
@findleyr
Copy link
Contributor

CC @adonovan -- I believe this should be fixed with the new analysis driver, but it requires validation.

@adonovan
Copy link
Member

adonovan commented Dec 22, 2022

This was indeed fixed at head by https://go.dev/cl/443099. (printf wrappers were the subject of a test case in that CL.)

@findleyr findleyr modified the milestones: gopls/later, gopls/v0.12.0 Dec 22, 2022
@golang golang locked and limited conversation to collaborators Dec 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls/analysis Issues related to running analysis in gopls gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants