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: VSCode with go module suddenly shows undeclared name: L LSP[line, character] #33477

Closed
elico opened this issue Aug 5, 2019 · 11 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@elico
Copy link

elico commented Aug 5, 2019

What version of Go are you using (go version)?

$ go version
go version go1.12.7 linux/amd64

Does this issue reproduce with the latest release?

Yes, but only on my current Ubuntu 18.04, on a fresh Debian 10 it works as expected.

What operating system and processor architecture are you using (go env)?

Ubuntu 18.04

go env Output
$ go env
GOARCH="amd64"
GOBIN="/home/eliezer/go_projects/bin"
GOCACHE="/home/eliezer/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/eliezer/go_projects"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build997023063=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Open Visual Studio Code.
Add the project folder V1.
Add three new xyz.go files into the project folder making it a basic V2
Opened one of the new files tls.go

What did you expect to see?

I expected the go module which uses gopls to show missing variables and other parts of the code as errors.

What did you see instead?

An screenshot link:
https://pasteboard.co/IrkFAnp.png

Lots of error lines such as below which ends with the source as LSP:

{
	"resource": "/home/eliezer/Scripts/golang-http-proxy2/filtering.go",
	"owner": "_generated_diagnostic_collection_name_#0",
	"severity": 8,
	"message": "undeclared name: RequestTimeout",
	"source": "LSP",
	"startLineNumber": 36,
	"startColumn": 27,
	"endLineNumber": 36,
	"endColumn": 41
}

{
	"resource": "/home/eliezer/Scripts/golang-http-proxy2/filtering.go",
	"owner": "_generated_diagnostic_collection_name_#0",
	"severity": 8,
	"message": "undeclared name: MaxIdleConnections",
	"source": "LSP",
	"startLineNumber": 41,
	"startColumn": 26,
	"endLineNumber": 41,
	"endColumn": 44
}
@gopherbot gopherbot added this to the Unreleased milestone Aug 5, 2019
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Aug 5, 2019
@stamblerre
Copy link
Contributor

Can you please share your gopls logs? See https://github.com/golang/go/wiki/gopls#capturing-gopls-logs for how to find them.

Also, can you try cding into /home/eliezer/Scripts/golang-http-proxy2 and running gopls -v -rpc.trace check filtering.go?

@stamblerre
Copy link
Contributor

Also, please note that you have to open VSCode at the module root, i.e., with the directory that contains the go.mod file (see #32394) -- I don't see a go.mod file in your screenshot.

@stamblerre stamblerre added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Aug 5, 2019
@elico
Copy link
Author

elico commented Aug 6, 2019

First, there is no go.mod since on this specific project I am not using go.mod and it's the same in many other projects which works perfectly fine.
I installed a clean VSCode and GoLang on a Debian 10, Oracle Linux 8, Ubuntu 18.04.2 (VM's)
(My install script: https://gist.github.com/elico/89d4c5106493e521aef29b23912ddd24 )
They all work as expected and shows the next screen:
https://pasteboard.co/IrqFzJ3.png
(I did some changes in the code so proxy.go is the only one with missing variables for now)

I assume it's something local to the Desktop I am working.
Until now I have tried to:

  • remove any GoLang folders and reinstall
  • remove VSCode and reinstall

I am sure that if it works as expected on a clean system so, maybe I missed something on my cleanup?
Edit:...
100% the cleanup wasn't complete.
I have tried to run:
cd ~ && rm -rf .vscode && rm -rf .config/Code

Which cleaned up anything VSCode has in my local user directory and now it works as expected.
I saved the old .config/Code directory for now in case I would like to make sure what went wrong.
(Seems to work fine now(no need for go.mod...)

gopls -v -rpc.trace check filtering.go Output
$ gopls -v -rpc.trace check filtering.go
2019/08/06 13:24:59 Info:21.908007ms for GOROOT= GOPATH=/home/eliezer/go_projects GO111MODULE= PWD=/home/eliezer/Scripts/golang-http-proxy2 go "list" "-e" "-json" "-compiled=true" "-test=true" "-export=false" "-deps=true" "-find=false" "--" "builtin", stderr: <<>>
2019/08/06 13:24:59 Info:Build info
----------
version v0.1.3-cmd.gopls, built in $GOPATH mode

Go info

go version go1.12.7 linux/amd64

GOARCH="amd64"
GOBIN="/home/eliezer/go_projects/bin"
GOCACHE="/home/eliezer/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/eliezer/go_projects"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build198551453=/tmp/go-build -gno-record-gcc-switches"
2019/08/06 13:24:59 Info:7.895657ms for GOROOT= GOPATH=/home/eliezer/go_projects GO111MODULE= PWD=/home/eliezer/Scripts/golang-http-proxy2 go "list" "-e" "-json" "-compiled=true" "-test=true" "-export=false" "-deps=true" "-find=false" "--" "/home/eliezer/Scripts/golang-http-proxy2", stderr: <<>>
2019/08/06 13:24:59 Info:120.593033ms for GOROOT= GOPATH=/home/eliezer/go_projects GO111MODULE= PWD=/home/eliezer/Scripts/golang-http-proxy2 go "list" "-e" "-json" "-compiled=true" "-test=true" "-export=false" "-deps=true" "-find=false" "--" "/home/eliezer/Scripts/golang-http-proxy2/filtering.go", stderr: <<>>
2019/08/06 13:24:59 Info:go/packages.Load
packages = 1
2019/08/06 13:24:59 Info:go/packages.Load
package = command-line-arguments
files = [/home/eliezer/Scripts/golang-http-proxy2/filtering.go]
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:126:5-12: undeclared name: verbose
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:127:3-12: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:145:5-12: undeclared name: verbose
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:146:3-12: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:147:3-12: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:148:3-12: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:149:3-12: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:150:3-12: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:151:3-12: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:153:4-13: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:155:3-12: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:161:7-14: undeclared name: verbose
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:162:5-14: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:169:7-14: undeclared name: verbose
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:170:5-14: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:171:5-14: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:177:6-13: undeclared name: verbose
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:178:4-13: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:211:5-12: undeclared name: verbose
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:212:3-12: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:213:3-12: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:218:6-13: undeclared name: verbose
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:219:4-13: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:224:6-13: undeclared name: verbose
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:225:4-13: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:230:6-13: undeclared name: verbose
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:231:4-13: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:233:10-23: undeclared name: defaultAnswer
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:234:11-24: undeclared name: defaultAnswer
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:239:9-22: undeclared name: defaultAnswer
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:89:5-12: undeclared name: verbose
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:90:3-12: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:94:26-35: undeclared name: filterUrl
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:102:23-27: undeclared name: user
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:102:29-33: undeclared name: pass
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:103:5-12: undeclared name: verbose
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:104:3-12: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:108:3-12: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:113:19-26: undeclared name: verbose
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:114:3-12: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:50:5-12: undeclared name: verbose
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:51:3-12: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:55:26-35: undeclared name: filterUrl
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:64:23-27: undeclared name: user
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:64:29-33: undeclared name: pass
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:65:5-12: undeclared name: verbose
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:66:3-12: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:70:3-12: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:71:3-12: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:77:3-12: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:78:3-12: undeclared name: L
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:36:27-41: undeclared name: RequestTimeout
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:41:26-44: undeclared name: MaxIdleConnections
/home/eliezer/Scripts/golang-http-proxy2/filtering.go:43:27-41: undeclared name: RequestTimeout

gopls debug log from VSCode Output
2019/08/06 13:48:52 Debug serving
	Port = 6060
[Trace - 1:48:52 PM] Received notification 'window/logMessage' in 0ms.
Params: {"type":3,"message":"18.126736ms for GOROOT=/usr/local/go GOPATH=/home/eliezer/go_projects GO111MODULE= PWD=/home/eliezer/Scripts/golang-http-proxy2 go \"list\" \"-e\" \"-json\" \"-compiled=true\" \"-test=true\" \"-export=false\" \"-deps=true\" \"-find=false\" \"--\" \"builtin\", stderr: \u003c\u003c\u003e\u003e\n"}

[Info - 1:48:52 PM] 18.126736ms for GOROOT=/usr/local/go GOPATH=/home/eliezer/go_projects GO111MODULE= PWD=/home/eliezer/Scripts/golang-http-proxy2 go "list" "-e" "-json" "-compiled=true" "-test=true" "-export=false" "-deps=true" "-find=false" "--" "builtin", stderr: <<>>

[Trace - 1:48:52 PM] Received response 'initialize - (0)' in 0ms.
Params: {"capabilities":{"textDocumentSync":{"openClose":true,"change":2,"save":{}},"hoverProvider":true,"completionProvider":{"triggerCharacters":["."]},"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"codeActionProvider":true,"documentFormattingProvider":true,"renameProvider":true,"documentLinkProvider":{},"typeDefinitionProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":"workspace/didChangeWorkspaceFolders"}}},"custom":null}

[Trace - 1:48:52 PM] Sending notification 'initialize' in 52ms.
Params: {"processId":8920,"rootPath":"/home/eliezer/Scripts/golang-http-proxy2","rootUri":"file:///home/eliezer/Scripts/golang-http-proxy2","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":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]}},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true},"textDocument":{"publishDiagnostics":{"relatedInformation":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},"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"]}},"definition":{"dynamicRegistration":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},"codeAction":{"dynamicRegistration":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true},"typeDefinition":{"dynamicRegistration":true},"implementation":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true}}},"initializationOptions":{"funcSnippetEnabled":false,"gocodeCompletionEnabled":true},"trace":"off","workspaceFolders":[{"uri":"file:///home/eliezer/Scripts/golang-http-proxy2","name":"golang-http-proxy2"}]}

[Trace - 1:48:52 PM] Sending response 'client/registerCapability - (1)' in 0ms.
Params: {}

[Trace - 1:48:52 PM] Received notification 'client/registerCapability' in 1ms.
Params: {"registrations":[{"id":"workspace/didChangeConfiguration","method":"workspace/didChangeConfiguration"},{"id":"workspace/didChangeWorkspaceFolders","method":"workspace/didChangeWorkspaceFolders"}]}

[Trace - 1:48:52 PM] Sending response 'workspace/configuration - (2)' in 0ms.
Params: [null,null]

[Trace - 1:48:52 PM] Received notification 'workspace/configuration' in 2ms.
Params: {"items":[{"scopeUri":"file:///home/eliezer/Scripts/golang-http-proxy2","section":"gopls"},{"scopeUri":"file:///home/eliezer/Scripts/golang-http-proxy2","section":"golang-http-proxy2"}]}

[Trace - 1:48:52 PM] Sending notification 'initialized' in 71ms.
Params: {}

[Trace - 1:48:52 PM] Received notification 'window/logMessage' in 0ms.
Params: {"type":3,"message":"Build info\n----------\nversion v0.1.3-cmd.gopls, built in $GOPATH mode\n\nGo info\n-------\ngo version go1.12.7 linux/amd64\n\nGOARCH="amd64"\nGOBIN="/home/eliezer/go_projects/bin"\nGOCACHE="/home/eliezer/.cache/go-build"\nGOEXE=""\nGOFLAGS=""\nGOHOSTARCH="amd64"\nGOHOSTOS="linux"\nGOOS="linux"\nGOPATH="/home/eliezer/go_projects"\nGOPROXY=""\nGORACE=""\nGOROOT="/usr/local/go"\nGOTMPDIR=""\nGOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"\nGCCGO="gccgo"\nCC="gcc"\nCXX="g++"\nCGO_ENABLED="1"\nGOMOD=""\nCGO_CFLAGS="-g -O2"\nCGO_CPPFLAGS=""\nCGO_CXXFLAGS="-g -O2"\nCGO_FFLAGS="-g -O2"\nCGO_LDFLAGS="-g -O2"\nPKG_CONFIG="pkg-config"\nGOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build344423364=/tmp/go-build -gno-record-gcc-switches"\n"}

[Info - 1:48:52 PM] Build info

version v0.1.3-cmd.gopls, built in $GOPATH mode

Go info

go version go1.12.7 linux/amd64

GOARCH="amd64"
GOBIN="/home/eliezer/go_projects/bin"
GOCACHE="/home/eliezer/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/eliezer/go_projects"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build344423364=/tmp/go-build -gno-record-gcc-switches"

[Trace - 1:48:52 PM] Sending notification 'textDocument/didOpen' in 72ms.
Params: {"textDocument":{"uri":"file:///home/eliezer/Scripts/golang-http-proxy2/filtering.go","languageId":"go","version":1,"text":"package main\n\nimport (\n\t"crypto/tls"\n\t"io/ioutil"\n\t"net"\n\t"net/http"\n\t"net/url"\n\t"regexp"\n\t"strings"\n\t"time"\n\n\t"golang.org/x/net/http2"\n)\n\nvar http_version = "1"\n\nvar v6_host = regexp.MustCompile(^%5B([\\:a-z0-9]+)\\%5D\\:([0-9]+))\nvar v6_uri = regexp.MustCompile(^^([a-z]+\\:\\/\\/)\\%5B([\\:a-z0-9]+)\\%5D(\\:)?([0-9]+)?(\\/.*))\n\nvar tlsConfig *tls.Config\nvar tlsCert *string\nvar pemCert []byte\nvar dontVerifyTls *bool\n\nvar filterClient *http.Client\n\nfunc newFilterClient() *http.Client {\n\tswitch http_version {\n\tcase "2":\n\t\treturn &http.Client{\n\t\t\tTransport: &http2.Transport{\n\t\t\t\t//\t\tMaxIdleConnsPerHost: MaxIdleConnections,\n\t\t\t\tTLSClientConfig: tlsConfig,\n\t\t\t},\n\t\t\tTimeout: time.Duration(RequestTimeout) * time.Second,\n\t\t}\n\tdefault:\n\t\treturn &http.Client{\n\t\t\tTransport: &http.Transport{\n\t\t\t\tMaxIdleConnsPerHost: MaxIdleConnections,\n\t\t\t},\n\t\t\tTimeout: time.Duration(RequestTimeout) * time.Second,\n\t\t}\n\t}\n\n}\n\nfunc check_tcp(host, port, srcip string) string {\n\tif verbose {\n\t\tL.Println("ERRlog: reporting query => \"" + host + ":" + port + "\"")\n\t\t//L.Println( "ERRlog: reporting url => \""+filter_url+"/tcp/?host="+host+"&port="+port+"&srcip="+srcip+"\"")\n\t}\n\n\ttesturl, _ := url.Parse(filterUrl + "tcp/")\n\ttesturlVals := url.Values{}\n\ttesturlVals.Set("host", host)\n\ttesturlVals.Set("port", port)\n\ttesturlVals.Set("bysrcip", srcip)\n\ttesturl.RawQuery = testurlVals.Encode()\n\n\trequest, err := http.NewRequest("GET", testurl.String(), nil)\n\trequest.Close = true\n\trequest.SetBasicAuth(user, pass)\n\tif verbose {\n\t\tL.Println("ERRlog: testing request details =>", request)\n\t}\n\tresp, err := filterClient.Do(request)\n\tif err != nil {\n\t\tL.Println("ERRlog: reporting a http connection error1 =>", err)\n\t\tL.Println("ERRlog: reporting a http connection error1 =>", request)\n\t\treturn "DUNO"\n\t}\n\tdefer resp.Body.Close()\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tL.Println("ERRlog: reporting a http connection error2 =>", err)\n\t\tL.Println("ERRlog: reporting a http connection error2 =>", request)\n\t\treturn "DUNO"\n\t}\n\n\tif body != nil {\n\t\treturn string(body)\n\t}\n\treturn "DUNO"\n}\n\nfunc check(requestUrl, srcip string) string {\n\tif verbose {\n\t\tL.Println("ERRlog: reporting query => \"" + requestUrl + "\"")\n\t\t//L.Println( "ERRlog: reporting url => \""+filter_url+"/url/?url="+encstr+"&srcip="+srcip+"\"")\n\t}\n\n\ttesturl, _ := url.Parse(filterUrl + "url/")\n\ttesturlVals := url.Values{}\n\ttesturlVals.Set("url", requestUrl)\n\ttesturlVals.Set("bysrcip", srcip)\n\ttesturl.RawQuery = testurlVals.Encode()\n\n\trequest, err := http.NewRequest("GET", testurl.String(), nil)\n\trequest.Close = true\n\trequest.SetBasicAuth(user, pass)\n\tif verbose {\n\t\tL.Println("ERRlog: testing request details =>", request)\n\t}\n\tresp, err := filterClient.Do(request)\n\tif err != nil {\n\t\tL.Println("ERRlog: reporting a http connection error => \"" + err.Error() + "\"")\n\t\treturn "DUNO"\n\t}\n\tdefer resp.Body.Close()\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil && verbose {\n\t\tL.Println("ERRlog: reporting body read error => \"" + err.Error() + "\"")\n\t}\n\tif body != nil {\n\t\treturn string(body)\n\t}\n\treturn "DUNO"\n}\n\nfunc process_request(incomming_request *http.Request) string {\n\n\tvar answer string\n\t//var srcip = "0"\n\tif verbose {\n\t\tL.Println("ERRlog: request from user => ")\n\t}\n\t//var uri url.URL\n\t//uri = incomming_request.URL\n\t// if (err != nil) && (!strings.Contains(err.Error(), "hexadecimal escape in host")) {\n\t// \tL.Println( err.Error())\n\t// \tL.Println( lparts[0]+" "+ans+" error=error parsing url")\n\t// }\n\n\tsrcip, , _ := net.SplitHostPort(incomming_request.RemoteAddr)\n\t// = srcip\n\t//_ = answer\n\t//_ = uri\n\t// Steps of a request inspection:\n\t// - find out if the request protocol from a choice of http\CONNECT\ftp\others\n\t// - Verify if the hostname is ipv6 or ipv4\n\t// - check with tcp for CONNECT\n\t// - check normally as a url if not CONNECT\n\tif verbose {\n\t\tL.Println("ERRlog: Details => ", "process_request function")\n\t\tL.Println("ERRlog: Details => ", incomming_request)\n\t\tL.Println("ERRlog: Details => ", incomming_request.URL)\n\t\tL.Println("ERRlog: Details => ", incomming_request.Method)\n\t\tL.Println("ERRlog: Details => ", incomming_request.Host)\n\t\tL.Println("ERRlog: Details => ", incomming_request.URL.Host)\n\t\tif len(incomming_request.URL.Opaque) > 0 {\n\t\t\tL.Println("ERRlog: Details (Opque) => ", incomming_request.URL.Opaque)\n\t\t}\n\t\tL.Println("ERRlog: Details => ", incomming_request.RemoteAddr)\n\t}\n\tswitch {\n\tcase incomming_request.Method == "CONNECT":\n\t\thost, port, err := net.SplitHostPort(incomming_request.URL.Host)\n\t\tif err != nil {\n\t\t\tif verbose {\n\t\t\t\tL.Println("ERRlog: Details ERR => ", err)\n\t\t\t}\n\t\t\tif strings.Contains(err.Error(), "missing port in address") {\n\t\t\t\tanswer = "DUNO"\n\t\t\t}\n\t\t\tanswer = "ERR"\n\t\t} else {\n\t\t\tif verbose {\n\t\t\t\tL.Println("ERRlog: Details HOST => ", host)\n\t\t\t\tL.Println("ERRlog: Details PORT => ", port)\n\t\t\t}\n\t\t\tanswer = check_tcp(host, port, srcip)\n\t\t}\n\tdefault:\n\t\tanswer = check(incomming_request.URL.String(), srcip)\n\t\tif verbose {\n\t\t\tL.Println("ERRlog: Details ANSWER for default => ", answer)\n\t\t}\n\t}\n\t/\n\t\tif (err != nil) && strings.Contains(err.Error(), "hexadecimal escape in host") {\n\t\t\tres := v6_uri.FindStringSubmatch(lparts[1])\n\t\t\tif len(res) == 4 {\n\t\t\t\tanswer = check(res[1]+"["+res[2]+"]"+res[3]+res[4], srcip)\n\t\t\t}\n\t\t\tif len(res) == 6 {\n\t\t\t\tanswer = check(res[1]+"["+res[2]+"]"+res[3]+res[4]+res[5], srcip)\n\t\t\t}\n\n\t\t} else if (incomming_request.Method == "CONNECT") && v6_host.MatchString(incomming_request.Host) {\n\t\t\tres := v6_host.FindStringSubmatch(incomming_request.Host)\n\t\t\thost := net.ParseIP(res[1])\n\t\t\tif host != nil {\n\t\t\t\tanswer = check_tcp(net.IP.String(host), res[2], srcip)\n\t\t\t} else {\n\t\t\t\tanswer = check_tcp(res[1], res[2], srcip)\n\t\t\t}\n\t\t} else if len(uri.Opaque) > 0 {\n\t\t\t// The next uri.Scheme is being exploited and used for the host string\n\t\t\tanswer = check_tcp(incomming_request.URL.Scheme, incomming_request.URL.Opaque, srcip)\n\t\t} else if lparts[2] == "CONNECT" {\n\t\t\t//Counting on that squid will never send bougous ip:port with a connect\n\t\t\thost_ip := strings.Split(lparts[1], ":")\n\t\t\tanswer = check_tcp(host_ip[0], host_ip[1], srcip)\n\n\t\t} else {\n\t\t\tanswer = check(incomming_request.URL.String(), srcip)\n\t\t}\n\t/\n\tif verbose {\n\t\tL.Println("ERRlog: reporting answer size => ", len(answer))\n\t\tL.Println("ERRlog: reporting answer => ", answer)\n\n\t}\n\n\tif strings.HasPrefix(answer, "ERR") || strings.HasPrefix(answer, "1") {\n\t\tif verbose {\n\t\t\tL.Println("ERRlog: reporting answer startsWith => \"ERR\"")\n\t\t}\n\t\treturn "ERR rate=100"\n\t}\n\tif strings.Contains(answer, "not found") || strings.HasPrefix(answer, "OK") {\n\t\tif verbose {\n\t\t\tL.Println("ERRlog: reporting answer startsWith => \"OK\" or \"not found\"")\n\t\t}\n\t\treturn "OK"\n\t}\n\tif strings.HasPrefix(answer, "DUNO") {\n\t\tif verbose {\n\t\t\tL.Println("ERRlog: reporting answer startsWith => \"DUNO\"")\n\t\t}\n\t\tif len(defaultAnswer) > 0 {\n\t\t\treturn defaultAnswer + " rate=101"\n\t\t} else {\n\t\t\treturn "OK state=DUNO"\n\t\t}\n\t}\n\treturn defaultAnswer + " rate=102"\n}\n"}}

[Trace - 1:48:52 PM] Received notification 'window/logMessage' in 0ms.
Params: {"type":3,"message":"22.767493ms for GOROOT=/usr/local/go GOPATH=/home/eliezer/go_projects GO111MODULE= PWD=/home/eliezer/Scripts/golang-http-proxy2 go "list" "-e" "-json" "-compiled=true" "-test=true" "-export=false" "-deps=true" "-find=false" "--" "/home/eliezer/Scripts/golang-http-proxy2", stderr: \u003c\u003c\u003e\u003e\n"}

[Info - 1:48:52 PM] 22.767493ms for GOROOT=/usr/local/go GOPATH=/home/eliezer/go_projects GO111MODULE= PWD=/home/eliezer/Scripts/golang-http-proxy2 go "list" "-e" "-json" "-compiled=true" "-test=true" "-export=false" "-deps=true" "-find=false" "--" "/home/eliezer/Scripts/golang-http-proxy2", stderr: <<>>

[Info - 1:48:53 PM] 119.616384ms for GOROOT=/usr/local/go GOPATH=/home/eliezer/go_projects GO111MODULE= PWD=/home/eliezer/Scripts/golang-http-proxy2 go "list" "-e" "-json" "-compiled=true" "-test=true" "-export=false" "-deps=true" "-find=false" "--" "/home/eliezer/Scripts/golang-http-proxy2/filtering.go", stderr: <<>>

[Trace - 1:48:53 PM] Received notification 'window/logMessage' in 0ms.
Params: {"type":3,"message":"119.616384ms for GOROOT=/usr/local/go GOPATH=/home/eliezer/go_projects GO111MODULE= PWD=/home/eliezer/Scripts/golang-http-proxy2 go "list" "-e" "-json" "-compiled=true" "-test=true" "-export=false" "-deps=true" "-find=false" "--" "/home/eliezer/Scripts/golang-http-proxy2/filtering.go", stderr: \u003c\u003c\u003e\u003e\n"}

[Trace - 1:48:53 PM] Received notification 'window/logMessage' in 0ms.
Params: {"type":3,"message":"go/packages.Load\n\tpackage = command-line-arguments\n\tfiles = [/home/eliezer/Scripts/golang-http-proxy2/filtering.go]"}

[Trace - 1:48:53 PM] Received notification 'window/logMessage' in 0ms.
Params: {"type":3,"message":"go/packages.Load\n\tpackages = 1"}

[Info - 1:48:53 PM] go/packages.Load
package = command-line-arguments
files = [/home/eliezer/Scripts/golang-http-proxy2/filtering.go]
[Info - 1:48:53 PM] go/packages.Load
packages = 1
[Trace - 1:48:53 PM] Received response 'textDocument/documentSymbol - (1)' in 0ms.
Params: [{"name":"http_version","detail":"string","kind":13,"range":{"start":{"line":15,"character":0},"end":{"line":15,"character":22}},"selectionRange":{"start":{"line":15,"character":4},"end":{"line":15,"character":16}}},{"name":"v6_host","detail":"*regexp.Regexp","kind":13,"range":{"start":{"line":17,"character":0},"end":{"line":17,"character":67}},"selectionRange":{"start":{"line":17,"character":4},"end":{"line":17,"character":11}}},{"name":"v6_uri","detail":"*regexp.Regexp","kind":13,"range":{"start":{"line":18,"character":0},"end":{"line":18,"character":92}},"selectionRange":{"start":{"line":18,"character":4},"end":{"line":18,"character":10}}},{"name":"tlsConfig","detail":"*tls.Config","kind":13,"range":{"start":{"line":20,"character":0},"end":{"line":20,"character":25}},"selectionRange":{"start":{"line":20,"character":4},"end":{"line":20,"character":13}}},{"name":"tlsCert","detail":"*string","kind":13,"range":{"start":{"line":21,"character":0},"end":{"line":21,"character":19}},"selectionRange":{"start":{"line":21,"character":4},"end":{"line":21,"character":11}}},{"name":"pemCert","detail":"[]byte","kind":13,"range":{"start":{"line":22,"character":0},"end":{"line":22,"character":18}},"selectionRange":{"start":{"line":22,"character":4},"end":{"line":22,"character":11}}},{"name":"dontVerifyTls","detail":"*bool","kind":13,"range":{"start":{"line":23,"character":0},"end":{"line":23,"character":23}},"selectionRange":{"start":{"line":23,"character":4},"end":{"line":23,"character":17}}},{"name":"filterClient","detail":"*http.Client","kind":13,"range":{"start":{"line":25,"character":0},"end":{"line":25,"character":29}},"selectionRange":{"start":{"line":25,"character":4},"end":{"line":25,"character":16}}},{"name":"newFilterClient","detail":"()","kind":12,"range":{"start":{"line":27,"character":0},"end":{"line":46,"character":1}},"selectionRange":{"start":{"line":27,"character":5},"end":{"line":27,"character":20}}},{"name":"check_tcp","detail":"(host string, port string, srcip string)","kind":12,"range":{"start":{"line":48,"character":0},"end":{"line":85,"character":1}},"selectionRange":{"start":{"line":48,"character":5},"end":{"line":48,"character":14}}},{"name":"check","detail":"(requestUrl string, srcip string)","kind":12,"range":{"start":{"line":87,"character":0},"end":{"line":119,"character":1}},"selectionRange":{"start":{"line":87,"character":5},"end":{"line":87,"character":10}}},{"name":"process_request","detail":"(incomming_request *http.Request)","kind":12,"range":{"start":{"line":121,"character":0},"end":{"line":239,"character":1}},"selectionRange":{"start":{"line":121,"character":5},"end":{"line":121,"character":20}}}]

[Trace - 1:48:53 PM] Sending notification 'textDocument/documentSymbol' in 933ms.
Params: {"textDocument":{"uri":"file:///home/eliezer/Scripts/golang-http-proxy2/filtering.go"}}

[Trace - 1:48:53 PM] Received response 'textDocument/codeAction - (2)' in 0ms.
Params: [{"title":"Organize Imports","kind":"source.organizeImports","edit":{"changes":{"file:///home/eliezer/Scripts/golang-http-proxy2/filtering.go":[]}}}]

[Trace - 1:48:53 PM] Received response 'textDocument/documentLink - (3)' in 0ms.
Params: [{"range":{"start":{"line":3,"character":1},"end":{"line":3,"character":13}},"target":"https://godoc.org/crypto/tls"},{"range":{"start":{"line":4,"character":1},"end":{"line":4,"character":12}},"target":"https://godoc.org/io/ioutil"},{"range":{"start":{"line":5,"character":1},"end":{"line":5,"character":6}},"target":"https://godoc.org/net"},{"range":{"start":{"line":6,"character":1},"end":{"line":6,"character":11}},"target":"https://godoc.org/net/http"},{"range":{"start":{"line":7,"character":1},"end":{"line":7,"character":10}},"target":"https://godoc.org/net/url"},{"range":{"start":{"line":8,"character":1},"end":{"line":8,"character":9}},"target":"https://godoc.org/regexp"},{"range":{"start":{"line":9,"character":1},"end":{"line":9,"character":10}},"target":"https://godoc.org/strings"},{"range":{"start":{"line":10,"character":1},"end":{"line":10,"character":7}},"target":"https://godoc.org/time"},{"range":{"start":{"line":12,"character":1},"end":{"line":12,"character":25}},"target":"https://godoc.org/golang.org/x/net/http2"}]

[Trace - 1:48:53 PM] Sending notification 'textDocument/codeAction' in 995ms.
Params: {"textDocument":{"uri":"file:///home/eliezer/Scripts/golang-http-proxy2/filtering.go"},"range":{"start":{"line":66,"character":2},"end":{"line":66,"character":2}},"context":{"diagnostics":[]}}

[Trace - 1:48:53 PM] Sending notification 'textDocument/documentLink' in 995ms.
Params: {"textDocument":{"uri":"file:///home/eliezer/Scripts/golang-http-proxy2/filtering.go"}}

[Trace - 1:48:53 PM] Received response 'textDocument/codeAction - (4)' in 0ms.
Params: [{"title":"Organize Imports","kind":"source.organizeImports","edit":{"changes":{"file:///home/eliezer/Scripts/golang-http-proxy2/filtering.go":[]}}}]

[Trace - 1:48:53 PM] Sending notification '$/cancelRequest' in 698ms.
Params: {"id":2}

[Trace - 1:48:53 PM] Sending notification 'textDocument/codeAction' in 700ms.
Params: {"textDocument":{"uri":"file:///home/eliezer/Scripts/golang-http-proxy2/filtering.go"},"range":{"start":{"line":66,"character":2},"end":{"line":66,"character":2}},"context":{"diagnostics":[]}}

[Trace - 1:48:53 PM] Received notification 'textDocument/publishDiagnostics' in 1ms.
Params: {"uri":"file:///home/eliezer/Scripts/golang-http-proxy2/filtering.go","diagnostics":[{"range":{"start":{"line":125,"character":4},"end":{"line":125,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: verbose"},{"range":{"start":{"line":126,"character":2},"end":{"line":126,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":144,"character":4},"end":{"line":144,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: verbose"},{"range":{"start":{"line":145,"character":2},"end":{"line":145,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":146,"character":2},"end":{"line":146,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":147,"character":2},"end":{"line":147,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":148,"character":2},"end":{"line":148,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":149,"character":2},"end":{"line":149,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":150,"character":2},"end":{"line":150,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":152,"character":3},"end":{"line":152,"character":12}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":154,"character":2},"end":{"line":154,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":160,"character":6},"end":{"line":160,"character":13}},"severity":1,"source":"LSP","message":"undeclared name: verbose"},{"range":{"start":{"line":161,"character":4},"end":{"line":161,"character":13}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":168,"character":6},"end":{"line":168,"character":13}},"severity":1,"source":"LSP","message":"undeclared name: verbose"},{"range":{"start":{"line":169,"character":4},"end":{"line":169,"character":13}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":170,"character":4},"end":{"line":170,"character":13}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":176,"character":5},"end":{"line":176,"character":12}},"severity":1,"source":"LSP","message":"undeclared name: verbose"},{"range":{"start":{"line":177,"character":3},"end":{"line":177,"character":12}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":210,"character":4},"end":{"line":210,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: verbose"},{"range":{"start":{"line":211,"character":2},"end":{"line":211,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":212,"character":2},"end":{"line":212,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":217,"character":5},"end":{"line":217,"character":12}},"severity":1,"source":"LSP","message":"undeclared name: verbose"},{"range":{"start":{"line":218,"character":3},"end":{"line":218,"character":12}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":223,"character":5},"end":{"line":223,"character":12}},"severity":1,"source":"LSP","message":"undeclared name: verbose"},{"range":{"start":{"line":224,"character":3},"end":{"line":224,"character":12}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":229,"character":5},"end":{"line":229,"character":12}},"severity":1,"source":"LSP","message":"undeclared name: verbose"},{"range":{"start":{"line":230,"character":3},"end":{"line":230,"character":12}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":232,"character":9},"end":{"line":232,"character":22}},"severity":1,"source":"LSP","message":"undeclared name: defaultAnswer"},{"range":{"start":{"line":233,"character":10},"end":{"line":233,"character":23}},"severity":1,"source":"LSP","message":"undeclared name: defaultAnswer"},{"range":{"start":{"line":238,"character":8},"end":{"line":238,"character":21}},"severity":1,"source":"LSP","message":"undeclared name: defaultAnswer"},{"range":{"start":{"line":88,"character":4},"end":{"line":88,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: verbose"},{"range":{"start":{"line":89,"character":2},"end":{"line":89,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":93,"character":25},"end":{"line":93,"character":34}},"severity":1,"source":"LSP","message":"undeclared name: filterUrl"},{"range":{"start":{"line":101,"character":22},"end":{"line":101,"character":26}},"severity":1,"source":"LSP","message":"undeclared name: user"},{"range":{"start":{"line":101,"character":28},"end":{"line":101,"character":32}},"severity":1,"source":"LSP","message":"undeclared name: pass"},{"range":{"start":{"line":102,"character":4},"end":{"line":102,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: verbose"},{"range":{"start":{"line":103,"character":2},"end":{"line":103,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":107,"character":2},"end":{"line":107,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":112,"character":18},"end":{"line":112,"character":25}},"severity":1,"source":"LSP","message":"undeclared name: verbose"},{"range":{"start":{"line":113,"character":2},"end":{"line":113,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":49,"character":4},"end":{"line":49,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: verbose"},{"range":{"start":{"line":50,"character":2},"end":{"line":50,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":54,"character":25},"end":{"line":54,"character":34}},"severity":1,"source":"LSP","message":"undeclared name: filterUrl"},{"range":{"start":{"line":63,"character":22},"end":{"line":63,"character":26}},"severity":1,"source":"LSP","message":"undeclared name: user"},{"range":{"start":{"line":63,"character":28},"end":{"line":63,"character":32}},"severity":1,"source":"LSP","message":"undeclared name: pass"},{"range":{"start":{"line":64,"character":4},"end":{"line":64,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: verbose"},{"range":{"start":{"line":65,"character":2},"end":{"line":65,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":69,"character":2},"end":{"line":69,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":70,"character":2},"end":{"line":70,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":76,"character":2},"end":{"line":76,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":77,"character":2},"end":{"line":77,"character":11}},"severity":1,"source":"LSP","message":"undeclared name: L"},{"range":{"start":{"line":35,"character":26},"end":{"line":35,"character":40}},"severity":1,"source":"LSP","message":"undeclared name: RequestTimeout"},{"range":{"start":{"line":40,"character":25},"end":{"line":40,"character":43}},"severity":1,"source":"LSP","message":"undeclared name: MaxIdleConnections"},{"range":{"start":{"line":42,"character":26},"end":{"line":42,"character":40}},"severity":1,"source":"LSP","message":"undeclared name: RequestTimeout"}]}

[Trace - 1:48:54 PM] Received response 'textDocument/codeAction - (5)' in 0ms.
Params: [{"title":"Organize Imports","kind":"source.organizeImports","edit":{"changes":{"file:///home/eliezer/Scripts/golang-http-proxy2/filtering.go":[]}}}]

[Trace - 1:48:54 PM] Sending notification 'textDocument/codeAction' in 17ms.
Params: {"textDocument":{"uri":"file:///home/eliezer/Scripts/golang-http-proxy2/filtering.go"},"range":{"start":{"line":66,"character":2},"end":{"line":66,"character":2}},"context":{"diagnostics":[]}}

[Trace - 1:49:03 PM] Received response 'textDocument/codeAction - (6)' in 0ms.
Params: [{"title":"Organize Imports","kind":"source.organizeImports","edit":{"changes":{"file:///home/eliezer/Scripts/golang-http-proxy2/filtering.go":[]}}}]

[Trace - 1:49:03 PM] Sending notification 'textDocument/codeAction' in 6ms.
Params: {"textDocument":{"uri":"file:///home/eliezer/Scripts/golang-http-proxy2/filtering.go"},"range":{"start":{"line":72,"character":2},"end":{"line":72,"character":2}},"context":{"diagnostics":[]}}

[Trace - 1:49:04 PM] Received response 'textDocument/codeAction - (7)' in 0ms.
Params: [{"title":"Organize Imports","kind":"source.organizeImports","edit":{"changes":{"file:///home/eliezer/Scripts/golang-http-proxy2/filtering.go":[]}}}]

[Trace - 1:49:04 PM] Sending notification 'textDocument/codeAction' in 8ms.
Params: {"textDocument":{"uri":"file:///home/eliezer/Scripts/golang-http-proxy2/filtering.go"},"range":{"start":{"line":0,"character":0},"end":{"line":240,"character":0}},"context":{"diagnostics":[{"range":{"start":{"line":15,"character":4},"end":{"line":15,"character":22}},"message":"don't use underscores in Go names; var http_version should be httpVersion","severity":2,"source":"go-lint"},{"range":{"start":{"line":17,"character":4},"end":{"line":17,"character":67}},"message":"don't use underscores in Go names; var v6_host should be v6Host","severity":2,"source":"go-lint"},{"range":{"start":{"line":18,"character":4},"end":{"line":18,"character":92}},"message":"don't use underscores in Go names; var v6_uri should be v6URI","severity":2,"source":"go-lint"},{"range":{"start":{"line":23,"character":4},"end":{"line":23,"character":23}},"message":"var dontVerifyTls should be dontVerifyTLS","severity":2,"source":"go-lint"},{"range":{"start":{"line":48,"character":5},"end":{"line":48,"character":49}},"message":"don't use underscores in Go names; func check_tcp should be checkTCP","severity":2,"source":"go-lint"},{"range":{"start":{"line":87,"character":11},"end":{"line":87,"character":45}},"message":"func parameter requestUrl should be requestURL","severity":2,"source":"go-lint"},{"range":{"start":{"line":121,"character":5},"end":{"line":121,"character":62}},"message":"don't use underscores in Go names; func process_request should be processRequest","severity":2,"source":"go-lint"},{"range":{"start":{"line":121,"character":21},"end":{"line":121,"character":62}},"message":"don't use underscores in Go names; func parameter incomming_request should be incommingRequest","severity":2,"source":"go-lint"},{"range":{"start":{"line":234,"character":9},"end":{"line":234,"character":10}},"message":"if block ends with a return statement, so drop this else and outdent its block","severity":2,"source":"go-lint"},{"range":{"start":{"line":125,"character":4},"end":{"line":125,"character":11}},"message":"undeclared name: verbose","severity":1,"source":"LSP"},{"range":{"start":{"line":126,"character":2},"end":{"line":126,"character":11}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":144,"character":4},"end":{"line":144,"character":11}},"message":"undeclared name: verbose","severity":1,"source":"LSP"},{"range":{"start":{"line":145,"character":2},"end":{"line":145,"character":11}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":146,"character":2},"end":{"line":146,"character":11}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":147,"character":2},"end":{"line":147,"character":11}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":148,"character":2},"end":{"line":148,"character":11}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":149,"character":2},"end":{"line":149,"character":11}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":150,"character":2},"end":{"line":150,"character":11}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":152,"character":3},"end":{"line":152,"character":12}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":154,"character":2},"end":{"line":154,"character":11}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":160,"character":6},"end":{"line":160,"character":13}},"message":"undeclared name: verbose","severity":1,"source":"LSP"},{"range":{"start":{"line":161,"character":4},"end":{"line":161,"character":13}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":168,"character":6},"end":{"line":168,"character":13}},"message":"undeclared name: verbose","severity":1,"source":"LSP"},{"range":{"start":{"line":169,"character":4},"end":{"line":169,"character":13}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":170,"character":4},"end":{"line":170,"character":13}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":176,"character":5},"end":{"line":176,"character":12}},"message":"undeclared name: verbose","severity":1,"source":"LSP"},{"range":{"start":{"line":177,"character":3},"end":{"line":177,"character":12}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":210,"character":4},"end":{"line":210,"character":11}},"message":"undeclared name: verbose","severity":1,"source":"LSP"},{"range":{"start":{"line":211,"character":2},"end":{"line":211,"character":11}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":212,"character":2},"end":{"line":212,"character":11}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":217,"character":5},"end":{"line":217,"character":12}},"message":"undeclared name: verbose","severity":1,"source":"LSP"},{"range":{"start":{"line":218,"character":3},"end":{"line":218,"character":12}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":223,"character":5},"end":{"line":223,"character":12}},"message":"undeclared name: verbose","severity":1,"source":"LSP"},{"range":{"start":{"line":224,"character":3},"end":{"line":224,"character":12}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":229,"character":5},"end":{"line":229,"character":12}},"message":"undeclared name: verbose","severity":1,"source":"LSP"},{"range":{"start":{"line":230,"character":3},"end":{"line":230,"character":12}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":232,"character":9},"end":{"line":232,"character":22}},"message":"undeclared name: defaultAnswer","severity":1,"source":"LSP"},{"range":{"start":{"line":233,"character":10},"end":{"line":233,"character":23}},"message":"undeclared name: defaultAnswer","severity":1,"source":"LSP"},{"range":{"start":{"line":238,"character":8},"end":{"line":238,"character":21}},"message":"undeclared name: defaultAnswer","severity":1,"source":"LSP"},{"range":{"start":{"line":88,"character":4},"end":{"line":88,"character":11}},"message":"undeclared name: verbose","severity":1,"source":"LSP"},{"range":{"start":{"line":89,"character":2},"end":{"line":89,"character":11}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":93,"character":25},"end":{"line":93,"character":34}},"message":"undeclared name: filterUrl","severity":1,"source":"LSP"},{"range":{"start":{"line":101,"character":22},"end":{"line":101,"character":26}},"message":"undeclared name: user","severity":1,"source":"LSP"},{"range":{"start":{"line":101,"character":28},"end":{"line":101,"character":32}},"message":"undeclared name: pass","severity":1,"source":"LSP"},{"range":{"start":{"line":102,"character":4},"end":{"line":102,"character":11}},"message":"undeclared name: verbose","severity":1,"source":"LSP"},{"range":{"start":{"line":103,"character":2},"end":{"line":103,"character":11}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":107,"character":2},"end":{"line":107,"character":11}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":112,"character":18},"end":{"line":112,"character":25}},"message":"undeclared name: verbose","severity":1,"source":"LSP"},{"range":{"start":{"line":113,"character":2},"end":{"line":113,"character":11}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":49,"character":4},"end":{"line":49,"character":11}},"message":"undeclared name: verbose","severity":1,"source":"LSP"},{"range":{"start":{"line":50,"character":2},"end":{"line":50,"character":11}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":54,"character":25},"end":{"line":54,"character":34}},"message":"undeclared name: filterUrl","severity":1,"source":"LSP"},{"range":{"start":{"line":63,"character":22},"end":{"line":63,"character":26}},"message":"undeclared name: user","severity":1,"source":"LSP"},{"range":{"start":{"line":63,"character":28},"end":{"line":63,"character":32}},"message":"undeclared name: pass","severity":1,"source":"LSP"},{"range":{"start":{"line":64,"character":4},"end":{"line":64,"character":11}},"message":"undeclared name: verbose","severity":1,"source":"LSP"},{"range":{"start":{"line":65,"character":2},"end":{"line":65,"character":11}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":69,"character":2},"end":{"line":69,"character":11}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":70,"character":2},"end":{"line":70,"character":11}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":76,"character":2},"end":{"line":76,"character":11}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":77,"character":2},"end":{"line":77,"character":11}},"message":"undeclared name: L","severity":1,"source":"LSP"},{"range":{"start":{"line":35,"character":26},"end":{"line":35,"character":40}},"message":"undeclared name: RequestTimeout","severity":1,"source":"LSP"},{"range":{"start":{"line":40,"character":25},"end":{"line":40,"character":43}},"message":"undeclared name: MaxIdleConnections","severity":1,"source":"LSP"},{"range":{"start":{"line":42,"character":26},"end":{"line":42,"character":40}},"message":"undeclared name: RequestTimeout","severity":1,"source":"LSP"}]}}

[Trace - 1:49:04 PM] Received response 'textDocument/formatting - (8)' in 0ms.
Params: []

[Trace - 1:49:04 PM] Sending notification 'textDocument/formatting' in 2ms.
Params: {"textDocument":{"uri":"file:///home/eliezer/Scripts/golang-http-proxy2/filtering.go"},"options":{"tabSize":4,"insertSpaces":false}}

[Trace - 1:49:04 PM] Sending notification 'textDocument/didSave' in 0ms.
Params: {"textDocument":{"uri":"file:///home/eliezer/Scripts/golang-http-proxy2/filtering.go","version":1}}

[Trace - 1:49:05 PM] Received response 'textDocument/codeAction - (9)' in 0ms.
Params: [{"title":"Organize Imports","kind":"source.organizeImports","edit":{"changes":{"file:///home/eliezer/Scripts/golang-http-proxy2/filtering.go":[]}}}]

[Trace - 1:49:05 PM] Sending notification 'textDocument/codeAction' in 8ms.
Params: {"textDocument":{"uri":"file:///home/eliezer/Scripts/golang-http-proxy2/filtering.go"},"range":{"start":{"line":72,"character":2},"end":{"line":72,"character":2}},"context":{"diagnostics":[]}}

@elico
Copy link
Author

elico commented Aug 6, 2019

Works after a full VSCode local settings directory cleanup.

@elico elico closed this as completed Aug 6, 2019
@Beilusquit90
Copy link

I have tried to run:
cd ~ && rm -rf .vscode && rm -rf .config/Code
Thanks!

@jshields
Copy link

jshields commented Nov 30, 2019

Removing the settings and reinstalling VSCode won't work if opting back in to using gopls after the reinstall. gopls seems to only work in Modules mode with a go.mod root to work off of. Edit: Or if your project is GOPATH based, make sure you open it as a VSCode workspace/project instead of opening individual files.
I ran go mod init github.com/jshields/my_project_name and the issue was resolved for me.

Related:
#33107 (comment)
https://github.com/microsoft/vscode-go/wiki/Go-modules-support-in-Visual-Studio-Code

@elico
Copy link
Author

elico commented Dec 1, 2019

Removing the settings and reinstalling VSCode won't work if opting back in to using gopls after the reinstall. gopls seems to only work in Modules mode with a go.mod root to work off of. I ran go mod init github.com/jshields/my_project_name and the issue was resolved for me.

Related:
#33107 (comment)
https://github.com/microsoft/vscode-go/wiki/Go-modules-support-in-Visual-Studio-Code

And in the case I am not working with a git or using a local git?

@elico elico reopened this Dec 1, 2019
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Dec 1, 2019
@jshields
Copy link

jshields commented Dec 1, 2019

And in the case I am not working with a git or using a local git?

@elico I just tried it for my env, and in this case you should be able to set "go.useLanguageServer": false to get things working. VSCode will use the "old style" Go tools that are command based instead of language server based.

The reason that deleting the settings was working for people seems to be because it defaulted this setting back to false. VSCode may prompt you to use the LSP, in which case you will have to say no if your project isn't Modules based. Edit: a properly configured project on GOPATH opened as a VSCode project should work with the LSP as well, even if not Modules based.

If you aren't working with Git, but want to use the newer LSP based code checks ("go.useLanguageServer": true in VSCode), it seems supplying any name for the module name works. I did go mod init fake_name and the unresolved name errors went away after reloading VSCode when LSP was toggled on.

@stamblerre
Copy link
Contributor

gopls works in both GOPATH and module mode, so if it's not working for you in GOPATH mode, please report an issue here, and I can help investigate. Otherwise, yes, you will have to initialize a module if you are working outside of your GOPATH (as is expected by the rest of the Go toolchain).

@jshields
Copy link

jshields commented Dec 2, 2019

Alright so I don't think there is any issue.

I was experiencing #33107 (comment) 😅
After reproducing the issue by removing my go.mod, the issue was resolved by opening the directory as a VSCode project instead of as individual files.
Also yes, when going without go.mod the project needs to be in $GOPATH/src.

I think this issue can be closed as it seems to represent environment issues rather than a bug.

Although, VSCode / gopls could give better error messaging, or rather VSCode should expose the logs of gopls more directly when there is an issue.
To debug this I had to go digging around in ~/.config/Code/logs, as it appears these steps don't apply to Linux based systems: https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#capturing-logs

If troubleshooting these kinds of issues is time consuming for other people as well, perhaps this should be a VSCode feature request to expose gopls error logs directly in the VSCode console. Not sure if that would make sense.

@stamblerre
Copy link
Contributor

Thanks for the report, @jshields. What you're referring to sounds like a duplicate of #31668, so I will close this issue in favor of that one.

@golang golang locked and limited conversation to collaborators Dec 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants