Skip to content

x/tools/gopls: identifies arbitrary dotted text in strings as links  #70033

Open
@marc-ostrow

Description

@marc-ostrow

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
go version go1.23.1 darwin/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
% $(go env GOPATH)/bin/gopls -v version
Build info
----------
golang.org/x/tools/gopls v0.16.2
    golang.org/x/tools/[email protected] h1:K1z03MlikHfaMTtG01cUeL5FAOTJnITuNe0TWOcg8tM=
    github.com/BurntSushi/[email protected] h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
    github.com/google/[email protected] h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
    golang.org/x/exp/[email protected] h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
    golang.org/x/[email protected] h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
    golang.org/x/[email protected] h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
    golang.org/x/[email protected] h1:Wm3cG5X6sZ0RSVRc/H1/sciC4AT6HAKgLCSH2lbpR/c=
    golang.org/x/[email protected] h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
    golang.org/x/[email protected] h1:6bJEg2w2kUHWlfdJaESYsmNfI1LKAZQi6zCa7LUn7eI=
    golang.org/x/[email protected] h1:SP0mPeg2PmGCu03V+61EcQiOjmpri2XijexKdzv8Z1I=
    honnef.co/go/[email protected] h1:9MDAWxMoSnB6QoSqiVr7P5mtkT9pOc1kSxchzPCnqJs=
    mvdan.cc/[email protected] h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
    mvdan.cc/xurls/[email protected] h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: go1.23.1
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
 % code -v
[1002/194224.823600:ERROR:codesign_util.cc(109)] SecCodeCheckValidity: Error Domain=NSOSStatusErrorDomain Code=-67062 "(null)" (-67062)
1.93.1
38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40
x64
  • Check your installed extensions to get the version of the VS Code Go extension

v0.42.1

  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
# Tools Configuration


## Environment

GOBIN: undefined
toolsGopath: 
gopath: /Users/marc/.asdf/installs/golang/1.23.1/packages
GOROOT: /Users/marc/.asdf/installs/golang/1.23.1/go
PATH: /usr/local/anaconda3/condabin:/Users/marc/.asdf/shims:/usr/local/opt/asdf/libexec/bin:/Users/marc/.cargo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/X11/bin:/Library/Apple/usr/bin:/usr/local/MacGPG2/bin:/Library/TeX/texbin:/Applications/Wireshark.app/Contents/MacOS:/Applications/iTerm.app/Contents/Resources/utilities

## Tools

	go:	/Users/marc/.asdf/shims/go: go version go1.23.1 darwin/amd64

	gopls:	/Users/marc/.asdf/installs/golang/1.23.1/packages/bin/gopls	(version: v0.16.2 built with go: go1.23.1)
	gotests:	/Users/marc/.asdf/installs/golang/1.23.1/packages/bin/gotests	(version: v1.6.0 built with go: go1.23.1)
	gomodifytags:	/Users/marc/.asdf/installs/golang/1.23.1/packages/bin/gomodifytags	(version: v1.17.0 built with go: go1.23.1)
	impl:	/Users/marc/.asdf/installs/golang/1.23.1/packages/bin/impl	(version: v1.4.0 built with go: go1.23.1)
	goplay:	/Users/marc/.asdf/installs/golang/1.23.1/packages/bin/goplay	(version: v1.0.0 built with go: go1.23.1)
	dlv:	/Users/marc/.asdf/installs/golang/1.23.1/packages/bin/dlv	(version: v1.23.1 built with go: go1.23.1)
	staticcheck:	/Users/marc/.asdf/installs/golang/1.23.1/packages/bin/staticcheck	(version: v0.5.1 built with go: go1.23.1)

## Go env

Workspace Folder (bugreport): /Users/marc/Projects/go/bugreport

	GO111MODULE=''
	GOARCH='amd64'
	GOBIN=''
	GOCACHE='/Users/marc/Library/Caches/go-build'
	GOENV='/Users/marc/Library/Application Support/go/env'
	GOEXE=''
	GOEXPERIMENT=''
	GOFLAGS=''
	GOHOSTARCH='amd64'
	GOHOSTOS='darwin'
	GOINSECURE=''
	GOMODCACHE='/Users/marc/.asdf/installs/golang/1.23.1/packages/pkg/mod'
	GONOPROXY='gitlab.com/nielsen-media/*'
	GONOSUMDB='gitlab.com/nielsen-media/*'
	GOOS='darwin'
	GOPATH='/Users/marc/.asdf/installs/golang/1.23.1/packages'
	GOPRIVATE='gitlab.com/nielsen-media/*'
	GOPROXY='https://proxy.golang.org,direct'
	GOROOT='/Users/marc/.asdf/installs/golang/1.23.1/go'
	GOSUMDB='sum.golang.org'
	GOTMPDIR=''
	GOTOOLCHAIN='auto'
	GOTOOLDIR='/Users/marc/.asdf/installs/golang/1.23.1/go/pkg/tool/darwin_amd64'
	GOVCS=''
	GOVERSION='go1.23.1'
	GODEBUG=''
	GOTELEMETRY='local'
	GOTELEMETRYDIR='/Users/marc/Library/Application Support/go/telemetry'
	GCCGO='gccgo'
	GOAMD64='v1'
	AR='ar'
	CC='clang'
	CXX='clang++'
	CGO_ENABLED='1'
	GOMOD='/Users/marc/Projects/go/bugreport/go.mod'
	GOWORK=''
	CGO_CFLAGS='-O2 -g'
	CGO_CPPFLAGS=''
	CGO_CXXFLAGS='-O2 -g'
	CGO_FFLAGS='-O2 -g'
	CGO_LDFLAGS='-O2 -g'
	PKG_CONFIG='pkg-config'
	GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/0d/8r9jqxd54rx2l7n0vqv2f0qm0000gn/T/go-build2339330694=/tmp/go-build -gno-record-gcc-switches -fno-common'

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

{
    "go.coverOnSingleTest": true,
    "go.coverOnSingleTestFile": true,
    "go.enableCodeLens": {},
    "go.formatTool": "goimports",
    "go.testFlags": [
        "-count=1",
        "-v",
        "-args",
        "-test.v"
    ],
    "go.testTimeout": "0",
    "go.toolsManagement.autoUpdate": false,
    "gopls": {
        "ui.semanticTokens": true,
    },
}

Describe the bug

A clear and concise description of what the bug.

Arbitrary dotted text in strings is being identified as links and is underlined when "editor.links" is enabled (set to true). When this extension, golang.go, is enabled, this happens. When this extension is disabled, it does not.

A clear and concise description of what you expected to happen.

I'd expect URLs having schema to be underscored as links when "editor.links" is enabled. Maybe "real" FQDNs not having a schema, can be detected and underscored as links, but would require name lookups, to verify dotted text as links, which would slow things down quite a bit.

Steps to reproduce the behavior:

  • Create a simple Go program
    • mkdir bugreport; cd bugreport
    • go mod init bugreport
    • create file main.go and paste the following content into main.go
package main

import (
	"log"
	"time"
)

type person struct {
	name string
	age  int
}

func main() {
	announcement := time.Date(2009, 11, 10, 0, 0, 0, 0, time.UTC)
	years := int(time.Since(announcement).Hours() / 24 / 365)
	p := person{name: "gopher", age: years}
	log.Printf("p.name is %q, p.age is %d", p.name, p.age)
	log.Printf("go.dev is my favorite site!")
	log.Printf("https://p.name is not a real site!")
}

With "editor.links" enabled (set to true), and the golang.go extension enabled, the following dotted text in the log.Printf format strings is underlined as links in main()

With "editor.links" enabled (set to true), and the golang.go extension disabled, the following dotted text in the log.Printf format strings is underlined as links in main()

With "editor.links" disabled (set to false), none of the dotted text is underlined as links.

Screenshots or recordings

If applicable, add screenshots or recordings to help explain your problem.

"editor.links" enabled && golang.go extension enabled

editor links-n-golang go

"editor.links" enabled && golang.go extension disabled

editor links-n-not-golang go

"editor.links" disabled && golang.go extension enabled

not-editor links-n-golang go

Metadata

Metadata

Assignees

No one assigned

    Labels

    ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.help wantedupstream-tools

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions