Skip to content

gopls: time.Format with the bad format "2006-02-01" causes gopls to hang (new analyzer)  #2406

@Phadin

Description

@Phadin

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.19 darwin/amd64
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.70.1 (Universal)
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.35.1
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

    go: /usr/local/bin/go: go version go1.19 darwin/amd64
    gotests: not installed
    gomodifytags: not installed
    impl: not installed
    goplay: not installed
    dlv: /Users/mbarri202/go/bin/dlv (version: v1.9.0 built with go: go1.19)
    staticcheck: /Users/mbarri202/go/bin/staticcheck (version: v0.3.3 built with go: go1.19)
    gopls: /Users/mbarri202/go/bin/gopls (version: v0.9.3 built with go: go1.19)

Describe the bug

Intellisense/gopls dies when using custom time format with time.Format. Go: Restart Language Server will work to restore functionality only if the offending code is removed or there are code errors preventing it from being run through. When the error occurs, hovering over text is stuck with a 'loading...' box, saving will hang on trying to access go formatting, and autocomplete will not function.

Steps to reproduce the behavior:

Go code that will cause the error:

now := time.Now()
nowFormatted := now.Format("2006-02-01")
fmt.Printf("Time: %v", nowFormatted)

Note that no error occurs with other time.Format functions such as now.Format(time.RFC822). It seemed to only occur with this custom format.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions