Thanks for the hint. My vscode project is built on Go source code tree, turns out gopls, the project (go compiler source) and go binary should be version compatible, I solved the problem by setting the source code path as GOROOT in settings.json and rebuild the extension tools.
On Friday, September 27, 2019 at 2:50:11 PM UTC+8, MUNGAI wrote: > > Hi, had the same issue when using Go modules. Does your project have > modules? > > Also, check GOPATH and GROOT setting. > > On Fri, Sep 27, 2019, 8:21 AM Xiangdong JI <xiang...@arm.com <javascript:>> > wrote: > >> Hi, >> >> I got a lot of 'undeclared name' errors with vscode, not sure it's >> something wrong with vscode or gopls, or my settings, hopefully someone can >> shed a light here, thanks. >> >> Take src/runtime/mbitmap.go as an example, seems that any cross-file >> reference is not recognized, tried to run 'gopls check mbitmap.go' in >> terminal and got the same output, >> the first few lines of gopls' output: >> >> 2019/09/27 05:16:28 Info:2019/09/27 05:16:28 96.267909ms for GOROOT= >> GOPATH=/home/xiaji01/.go GO111MODULE= >> PWD=/mnt/share/homes/xiaji01/src/go.svc/src/runtime go "list" "-e" "-json" >> "-compiled=true" "-test=true" "-export=false" "-deps=true" "-find=false" >> "--" "/mnt/share/homes/xiaji01/src/go.svc/src/runtime/mbitmap.go", stderr: >> <<>> >> 2019/09/27 05:16:28 Info:2019/09/27 05:16:28 go/packages.Load >> packages = 1 >> 2019/09/27 05:16:28 Info:2019/09/27 05:16:28 go/packages.Load >> package = command-line-arguments >> files = >> [/mnt/share/homes/xiaji01/src/go.svc/src/runtime/mbitmap.go] >> /mnt/share/homes/xiaji01/src/go.svc/src/runtime/mbitmap.go:150:29-41: >> undeclared name: heapAddrBits >> /mnt/share/homes/xiaji01/src/go.svc/src/runtime/mbitmap.go:150:43-57: >> undeclared name: heapArenaBytes >> /mnt/share/homes/xiaji01/src/go.svc/src/runtime/mbitmap.go:168:10-15: >> undeclared name: mspan >> /mnt/share/homes/xiaji01/src/go.svc/src/runtime/mbitmap.go:177:10-15: >> undeclared name: mspan >> /mnt/share/homes/xiaji01/src/go.svc/src/runtime/mbitmap.go:195:10-15: >> undeclared name: mspan >> /mnt/share/homes/xiaji01/src/go.svc/src/runtime/mbitmap.go:246:10-15: >> undeclared name: mspan >> >> >> $ gopls version >> golang.org/x/tools/gopls v0.1.7 >> golang.org/x/tools/gopls@v0.1.7 >> h1:YwKf8t9h69++qCtVmc2q6fVuetFXmmu9LKoPMYLZid4= >> >> $ go version >> go version devel +20f0bcb0c1 Sun Sep 22 17:10:30 2019 +0000 linux/amd64 >> >> >> [image: Capture.JPG] >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golan...@googlegroups.com <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/golang-nuts/d4000ccd-cb3d-4e8e-b2cf-6391311ce836%40googlegroups.com >> >> <https://groups.google.com/d/msgid/golang-nuts/d4000ccd-cb3d-4e8e-b2cf-6391311ce836%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/90522c8f-85ef-4869-bf03-fa2a14fae084%40googlegroups.com.