Getting issue while using golang in windows cannot find package golang.org/x/sys/windows

Hello Everyone, I was using Ubuntu since 1 year but due to some compatibility issues i have shifted back to windows. Ubuntu doesn’t support many applications and windows doesn’t support golang correctly.
I am using Windows, i am developing programs which needed to be ran on CentOS Servers so i need to compile my program for Linux using set GOOS=linux but that is not an problem.
i am using gookit color which is a popular module for printing coloured text using the code color.White.Printf , i have followed the steps to install that module from github using go get. but the vs code is throwing me this error :
error while importing github.com/gookit/color: cannot find package

"golang.org/x/sys/windows" in any of:
	C:\Program Files\Go\src\vendor\golang.org\x\sys\windows (vendor tree)
	C:\Program Files\Go\src\golang.org\x\sys\windows (from $GOROOT)
	C:\Users\91787\go\src\golang.org\x\sys\windows (from $GOPATH)

screenshot attached.

and while compiling, i ran these comands :

set GOOS=linux
go build -ldflags="-s -w" getpack_jet.go

and got this error :

C:\Program Files\Go\src\github.com\gookit\color\detect_windows.go:16:2: cannot find package "golang.org/x/sys/windows" in any of:
        C:\Program Files\Go\src\vendor\golang.org\x\sys\windows (vendor tree)
        C:\Program Files\Go\src\golang.org\x\sys\windows (from $GOROOT)
        C:\Users\91787\go\src\golang.org\x\sys\windows (from $GOPATH)

any one would able to help me ? please

What happens when you type “go mod tidy”?

Where i have to run it? i mean in which directory?

Getting this :

C:\Program Files\Go\src\github.com\gookit\color>go mod tidy
go: updating go.mod: open C:\Program Files\Go\src\github.com\gookit\color\go.mod: Access is denied.

C:\Program Files\Go\src\github.com\gookit\color>

Also tried running as administrator but same error.

At your project’s home.

@monsterlegend99 — Did you ever solve this? I am having the same problem.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.