Go Debug delve dlv Error Could Not Import

349 Views Asked by At

Source code: https://github.com/Calvinn097/gqlgentest

Installed go 1.19.5

dlv version is 1.20.1, installed from vscode command Go: Install/Update Tools

PS W:\workS\testgql> dlv version
Delve Debugger
Version: 1.20.1
Build: $Id: 96e65b6c615845d42e0e31d903f6475b0e4ece6e $

Followed https://gqlgen.com/ to setup example todo project

.vscode/launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        
        {
            "name": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${workspaceFolder}/server.go",
            // "envFile": "${workspaceFolder}/.env"

            
        }
        
    ]
}

Im using vscode F5 to launch dlv

After F5, debug console output produce this error

Starting: W:\usergo\go\bin\dlv.exe dap --listen=127.0.0.1:29675 from W:\workS\testgql
DAP server listening at: 127.0.0.1:29675
Build Error: go build -o W:\workS\testgql\__debug_bin.exe -gcflags all=-N -l .\server.go
# crypto/x509/pkix
W:\go\src\crypto\x509\pkix\pkix.go:10:2: could not import encoding/asn1 (EOF)
# crypto/rsa
W:\go\src\crypto\rsa\rsa.go:28:2: could not import crypto/internal/boring/bbig (EOF)
W:\go\src\crypto\rsa\rsa.go:30:2: could not import crypto/rand (EOF)
# crypto/ed25519
W:\go\src\crypto\ed25519\ed25519.go:19:13: could not import crypto/rand (EOF)
# vendor/golang.org/x/crypto/cryptobyte
W:\go\src\vendor\golang.org\x\crypto\cryptobyte\asn1.go:8:16: could not import encoding/asn1 (EOF)
# net/textproto
W:\go\src\net\textproto\textproto.go:31:2: could not import net (EOF)
# github.com/mitchellh/mapstructure
W:\usergo\go\pkg\mod\github.com\mitchellh\[email protected]\decode_hooks.go:7:2: could not import net (EOF)
# text/template
W:\go\src\text\template\exec.go:15:2: could not import text/template/parse (EOF)
W:\go\src\text\template\exec.go:131:15: invalid operation: s.node == nil (operator == not defined on untyped nil)
W:\go\src\text\template\exec.go:134:31: s.tmpl.ErrorContext undefined (type *Template has no field or method ErrorContext)
W:\go\src\text\template\exec.go:215:15: invalid operation: t.Tree == nil (operator == not defined on untyped nil)
W:\go\src\text\template\exec.go:215:24: t.Root undefined (type *Template has no field or method Root)
W:\go\src\text\template\exec.go:218:22: t.Root undefined (type *Template has no field or method Root)
W:\go\src\text\template\exec.go:234:19: invalid operation: tmpl.Tree == nil (operator == not defined on untyped nil)
W:\go\src\text\template\exec.go:234:31: tmpl.Root undefined (type *Template has no field or method Root)
W:\go\src\text\template\exec.go:439:26: tmpl.Root undefined (type *Template has no field or method Root)
W:\go\src\text\template\template.go:138:41: invalid operation: nt.Tree == nil (operator == not defined on untyped nil)
W:\go\src\text\template\template.go:138:41: too many errors
# vendor/golang.org/x/net/idna
W:\go\src\vendor\golang.org\x\net\idna\idna10.0.0.go:28:2: could not import golang.org/x/text/unicode/norm (EOF) (exit status 2)

go.mod

module gqluser

go 1.16

require (
    github.com/99designs/gqlgen v0.16.0
    github.com/vektah/gqlparser/v2 v2.2.0
)

I tried reinstalling go go version go1.19.5 windows/amd64 but fail

On another device f5 run without problem, also If I create hello.go and set launch.json to run hello.go that prints something, it is running succesfully

package main

import "fmt"

func main() {
    fmt.Println("Haiii")
}
1

There are 1 best solutions below

0
Calvin On

I tried changing go version and delve version the same as version on working device, F5 run successfully now. I have no idea what caused it

PS W:\workS\gqlusers> go version
go version go1.19.2 windows/amd64
PS W:\workS\gqlusers> dlv version
Delve Debugger
Version: 1.9.1
Build: $Id: d81b9fd12bfa603f3cf7a4bc842398bd61c42940 $