golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.78k stars 728 forks source link

import problem with github.com/go-playground/validator/v10 #3258

Closed emirefek closed 2 months ago

emirefek commented 3 months ago

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.22.1 windows/amd64` * Run `gopls -v version` to get version of Gopls from _the VS Code integrated terminal_. ``` Build info ---------- golang.org/x/tools/gopls v0.15.2 golang.org/x/tools/gopls@v0.15.2 h1:4JKt4inO8JaFW3l/Fh9X1k/5JQn+iUOpdc4/Lpi0mOs= github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= github.com/google/go-cmp@v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y= golang.org/x/mod@v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= golang.org/x/sync@v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= golang.org/x/sys@v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= golang.org/x/telemetry@v0.0.0-20240209200032-7b892fcb8a78 h1:vcVnuftN4J4UKLRcgetjzfU9FjjgXUUYUc3JhFplgV4= golang.org/x/text@v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/tools@v0.18.1-0.20240311201521-78fbdeb61842 h1:No0LMXYFkp3j4oEsPdtY8LUQz33gu79Rm9DE+izMeGQ= golang.org/x/vuln@v1.0.1 h1:KUas02EjQK5LTuIx1OylBQdKKZ9jeugs+HiqO5HormU= honnef.co/go/tools@v0.4.6 h1:oFEHCKeID7to/3autwsWfnuv69j3NsfcXbvJKuIcep8= mvdan.cc/gofumpt@v0.6.0 h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo= mvdan.cc/xurls/v2@v2.5.0 h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8= go: go1.22.1 ``` * Run `code -v` or `code-insiders -v` to get version of VS Code or VS Code Insiders. ``` 1.87.2 863d2581ecda6849923a2118d93a088b0745d9d6 x64 ``` * Check your installed extensions to get the version of the VS Code Go extension `v0.41.2` * Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > `Go: Locate Configured Go Tools` command. ``` # Tools Configuration ## Environment GOBIN: undefined toolsGopath: gopath: C:\Users\emire\go GOROOT: C:\Program Files\Go PATH: C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64_win\compiler;C:\Program Files\Microsoft\jdk-17.0.10.7-hotspot\bin;C:\Program Files\Microsoft MPI\Bin\;C:\Program Files\Microsoft\jdk-21.0.2.13-hotspot\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\PowerShell\7\;C:\Users\emire\AppData\Roaming\nvm;C:\Program Files\nodejs;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files\Docker\Docker\resources\bin;C:\runtimes\apache-maven-3.9.6\bin;C:\Program Files\Go\bin;C:\TDM-GCC-64\bin;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Users\emire\AppData\Local\NVIDIA\ChatWithRTX\env_nvd_rag\Lib\site-packages\torch\lib;C:\ProgramData\chocolatey\bin;C:\Program Files\WireGuard\;C:\Users\emire\AppData\Local\Microsoft\WindowsApps;C:\Users\emire\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\emire\AppData\Roaming\nvm;C:\Program Files\nodejs;C:\runtimes\apache-maven-3.9.6\bin;C:\Users\emire\go\bin;C:\runtimes\atlas;C:\Users\emire\.dotnet\tools ## Tools go: C:\Program Files\Go\bin\go.exe: go version go1.22.0 windows/amd64 gopls: C:\Users\emire\go\bin\gopls.exe (version: v0.15.2 built with go: go1.22.1) gotests: not installed gomodifytags: not installed impl: not installed goplay: not installed dlv: not installed staticcheck: C:\Users\emire\go\bin\staticcheck.exe (version: v0.4.6 built with go: go1.22.0) ## Go env Workspace Folder (go-mailer): c:\Users\emire\Desktop\go-mailer set GO111MODULE= set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\emire\AppData\Local\go-build set GOENV=C:\Users\emire\AppData\Roaming\go\env set GOEXE=.exe set GOEXPERIMENT= set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GOMODCACHE=C:\Users\emire\go\pkg\mod set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=C:\Users\emire\go set GOPRIVATE= set GOPROXY=https://proxy.golang.org,direct set GOROOT=C:\Program Files\Go set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLCHAIN=auto set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64 set GOVCS= set GOVERSION=go1.22.1 set GCCGO=gccgo set GOAMD64=v1 set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD=c:\Users\emire\Desktop\go-mailer\go.mod set GOWORK= set CGO_CFLAGS=-O2 -g set CGO_CPPFLAGS= set CGO_CXXFLAGS=-O2 -g set CGO_FFLAGS=-O2 -g set CGO_LDFLAGS=-O2 -g set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\emire\AppData\Local\Temp\go-build1678433315=/tmp/go-build -gno-record-gcc-switches ```

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.

Describe the bug

Cannot import V10 verison of "https://github.com/go-playground validator" with VSCode uses official GOLang plugin. Library maintainer claims it should work without issue.

Issue on library: https://github.com/go-playground/validator/issues/1229

Steps to reproduce the behavior:

  1. Create a go project
  2. go get github.com/go-playground/validator/v10
  3. try to import "github.com/go-playground/validator/v10"

Screenshots or recordings

91567124-2ce2-42f6-bf45-70ab1cd6f77c 304209888-ee8719bc-78dc-4162-96b8-2457a0ed9cff 304210257-1e0b9ac7-2ab4-4085-92e8-e8bac681678c
findleyr commented 3 months ago

@emirefek in your go.mod file I do not see a require for github.com/go-playground/validator. Also, it doesn't look like the validator package is actually used in the post_sendmail.go file.

I suspect that you saved without using the validator import (at which point the import was removed), then ran go mod tidy, removing the require. If you run go get again, it should work.

gopherbot commented 2 months ago

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)