1
votes

When importing golang.org/x/sys/windows in VSCode, I can only choose SIGDescribe, nothing else.

Hovering over the import, following errors appear.

error while importing golang.org/x/sys/windows: build constraints exclude all Go files in /home/username/go/pkg/mod/golang.org/x/[email protected]/windows

could not import golang.org/x/sys/windows (no required module provides package "golang.org/x/sys/windows")compilerBrokenImport

The manual command go get golang.org/x/sys/windows gives the following error message

Command 'gopls.go_get_package' failed: Error: err: exit status 1: stderr: package golang.org/x/sys/windows: build constraints exclude all Go files in /home/username/go/pkg/mod/golang.org/x/[email protected]/windows .

I already re-installed Golang and updated GoTools in VSCode, no changes.

Goal: The following code below should work.

package main

import "golang.org/x/sys/windows"

func main() {
    user32DLL := windows.NewLazyDLL("user32.dll")
}

OS: Ubuntu 21.04

GO Version: 1.16.6

Editor: VSCode 1.58.1

1
gopls still has limited support for cross-platform development. If the project builds with GOOS=windows, then it is fine. - Zyl
you are right, after GOOS=windows the program compiles and works, even VSCode lintings are full of errors and go import module windows does not recognize methods like NewLazyDLL. - worrath

1 Answers

0
votes

Make a folder somewhere something. Then make a file something/main.go:

package main
import "golang.org/x/sys/windows"

func main() {
   println(windows.EVENTLOG_ERROR_TYPE == 1)
}

Then build:

go mod init something
go mod tidy
go build