Installing github.com/rogpeppe/godef FAILED - go

I use Go: Install/Update Tools in VSCode to install gocode and godef but I get this error :
Installing github.com/stamblerre/gocode FAILED Installing
github.com/rogpeppe/godef FAILED
and in the output ->
""D:\Krittawat\Learn\GoWorkspace\src\github.com\stamblerre\gocode"
is not using a known version control system" and
""D:\Krittawat\Learn\GoWorkspace\src\github.com\stamblerre\gocode"
is not using a known version control system"
I check my GOPATH GOROOT GOBIN by using "go env"
and this is my GOPATH GOROOT and GOBIN
set GOPATH=D:\Krittawat\Learn\GoWorkspace
set GOROOT=D:\Krittawat\Programs\go1.12.7.windows-amd64\go
set GOBIN=
I don't know how to solve it. I searching for solutions, but nothing works.

Related

Windows pkg_config failed: `"pkg-config" "--libs" "--cflags" "dbus-1" "dbus-1 >= 1.6"` did not exit successfully

I'm attempting to compile a Rust app on windows, and I've hit a problem I don't know how to solve. Running cargo build produces:
--- stderr
pkg_config failed: `"pkg-config" "--libs" "--cflags" "dbus-1" "dbus-1 >= 1.6"` did not exit successfully: exit code: 1
--- stderr
Package dbus-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `dbus-1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'dbus-1' found
Package dbus-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `dbus-1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'dbus-1' found
One possible solution is to check whether packages
'libdbus-1-dev' and 'pkg-config' are installed:
On Ubuntu:
sudo apt install libdbus-1-dev pkg-config
On Fedora:
sudo dnf install dbus-devel pkgconf-pkg-config
Can this advice (to install libdbus-1-dev) be adjusted for Windows? What is the general process for such, in case I hit a similar problem on another package after resolving this one?

fatal error: 'dirent.h' file not found when trying to install gopls/Go tools via Visual Studio Code

I am trying to install the Go tools in Visual Studio Code and am getting the following error when installing gopls:
Tools environment: GOPATH=/Users/jal/go
Installing 1 tool at /Users/jal/go/bin in module mode.
gopls
Installing golang.org/x/tools/gopls#latest FAILED
{
"killed": false,
"code": 2,
"signal": null,
"cmd": "/opt/brew/bin/go install -v golang.org/x/tools/gopls#latest",
"stdout": "",
"stderr": "golang.org/x/tools/internal/fastwalk\n# golang.org/x/tools/internal/fastwalk\n../../go/pkg/mod/golang.org/x/tools#v0.2.1-0.20221101170700-b5bc717366b2/internal/fastwalk/fastwalk_darwin.go:11:10: fatal error: 'dirent.h' file not found\n#include <dirent.h>\n ^~~~~~~~~~\n1 error generated.\n"
}
1 tools failed to install.
gopls: failed to install gopls(golang.org/x/tools/gopls#latest): Error: Command failed: /opt/brew/bin/go install -v golang.org/x/tools/gopls#latest
golang.org/x/tools/internal/fastwalk
# golang.org/x/tools/internal/fastwalk
../../go/pkg/mod/golang.org/x/tools#v0.2.1-0.20221101170700-b5bc717366b2/internal/fastwalk/fastwalk_darwin.go:11:10: fatal error: 'dirent.h' file not found
#include <dirent.h>
^~~~~~~~~~
1 error generated.
I know I have dirent.h because I see results in my local Xcode SDKs when running find / -iregex ".*/dirent.h$" 2>/dev/null.
I am following the steps here: https://learn.microsoft.com/en-us/azure/developer/go/configure-visual-studio-code
My setup is:
Fresh install of go from Homebrew
Fresh install of VSCode macOS from go.dev/doc/install
Instal the Go plugin
In the Command Palette, search for and select "Go: Install/Update tools" and select all tools in the dropdown
All tools are installed successfully except for gopls. I have installed go via Homebrew and have also installed gopls via Homebrew but am not sure how to configure VSCode to point to this alternative gopls path.
The issue seemed to be due to a misconfigured or corrupted Xcode and command line tools.
I uninstalled and re-installed the latest version of Xcode, as well as the Command Line Tools package (this one is especially important) from here https://developer.apple.com/download/all/.
I had to do this despite xcode-select --install telling me everything was installed correctly and up to date.
Future issue discussion available here: https://github.com/golang/go/issues/56663

i am unable to install subzy tool in my linux it shows error

I tried to install this subzy tool from GitHub but it shows this kind of error and I can't install it I have faced the same problem with other programs written in (GO language).
I can clone the programs written in python but I am unable to clone the programs written in go language once I clone I don't know how to install them
****➜ ~ go install -v github.com/lukasikic/subzy#latest
go: finding a module f**or package github.com/mitchellh/go-homedir
go: finding module for package github.com/logrusorgru/aurora
go: found github.com/logrusorgru/aurora in github.com/logrusorgru/aurora v2.0.3+incompatible
go: found github.com/mitchellh/go-homedir in github.com/mitchellh/go-homedir v1.1.0
➜ ~ go get -u -v github.com/lukasikic/subzy
go get: installing executables with 'go get' in module mode is deprecated.
Use 'go install pkg#version' instead.
For more information, see https://golang.org/doc/go-get-install-deprecation
or run 'go help get' or 'go help install'.
➜ ~**
Welcome to the community,
Check the closed repo, whether it has go.mod and go.sum files
Check the version of the go (go mod is enforced in recent version meaning)
Check and learn about go mod and how to use (https://go.dev/blog/using-go-modules)

VSCODE faill to install tools in go module

when starting a go module on VSCode I get prompted to install some tool
choosing install the installation fails, below the logs in vscode terminal
VSCODE keeps yelling at me an "fail to install" stuff, simply because ignores my path
as you can see below
Tools environment: GOPATH=/home/go
Installing 1 tool at /home/go/bin in module mode.
gopls
Installing golang.org/x/tools/gopls FAILED
1 tools failed to install.
gopls: failed to install gopls(golang.org/x/tools/gopls): Error: Command failed: /usr/local/go/bin/go get -v golang.org/x/tools/gopls
go: writing stat cache: mkdir /home/go: permission denied
go: downloading golang.org/x/tools/gopls v0.5.1
go: downloading golang.org/x/tools v0.0.0-20201017001424-6003fad69a88
go get golang.org/x/tools/gopls: mkdir /home/go: permission denied
undefined
these are my GOPATH and GOROOT
# GOLANG
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$PATH
export PATH=$GOROOT/bin:$PATH
and this is my vscode settings.json
{
"[dart]": {
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.rulers": [
80
],
"editor.selectionHighlight": false,
"editor.suggest.snippetsPreventQuickSuggestions": false,
"editor.suggestSelection": "first",
"editor.tabCompletion": "onlySnippets",
"editor.wordBasedSuggestions": false
},
"workbench.iconTheme": "material-icon-theme",
"workbench.colorTheme": "One Dark Pro",
"dart.sdkPath": "/home/francesco/development/dart",
"dart.openDevTools": "flutter",
"go.formatTool": "goimports",
"dart.checkForSdkUpdates": false,
"go.useLanguageServer": true,
"go.inferGopath": false,
"go.gopath": "/home/go",
"go.goroot": "/usr/local/go"
}
what action should I take to fix the error?
Your error is:
go: writing stat cache: mkdir /home/go: permission denied
Go tries to write to /home/go. This folder is derived from:
export GOPATH=$HOME/go
So it looks your $HOME doesn't point to your home folder. GOPATH should point to a folder where you have write permission, because the module cache is located under GOPATH. So it should point to a folder under your user home, e.g. /home/francesco/go.
I recently solved this problem on my Windows machine. At first I had thought it was a file permissions problem. But it was a GOPATH environment variable problem.
I had it set to 2 values: C:\Program Files\Go (which is where I installed Go) and C:.... which was where I wanted all my Go projects to go.
So I removed the first entry. Just leaving GOPATH to point to the place on my hard drive where I wanted all my projects, and hey presto, problems gone, all tools installed correctly.
This may have been due to a previous version of Go not being entirely removed.

Cannot build open-source project

I'd like to contribute to an OSS project built with go, but I'm having hard time compiling it. It looks as if I'm missing something obvious.
I think the problem is related to how go is installed on my computer, and not to the project itself, thus I'm posting it here on StackOverflow, instead of project's "Issues" section.
Below is what I'm doing.
I've installed go using homebrew:
$ brew install go
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
libebml
==> Downloading https://homebrew.bintray.com/bottles/go-1.8.3.sierra.bottle.tar.gz
Already downloaded: /Users/gmile/Library/Caches/Homebrew/go-1.8.3.sierra.bottle.tar.gz
==> Pouring go-1.8.3.sierra.bottle.tar.gz
==> Caveats
A valid GOPATH is required to use the `go get` command.
If $GOPATH is not specified, $HOME/go will be used by default:
https://golang.org/doc/code.html#GOPATH
You may wish to add the GOROOT-based install location to your PATH:
export PATH=$PATH:/usr/local/opt/go/libexec/bin
==> Summary
🍺 /usr/local/Cellar/go/1.8.3: 7,035 files, 282.0MB
$
Then I cloned the repo:
$ hub clone lucapette/fakedata
I ran make setup (per instruction), which at first did not complete successfully:
$ make setup
go get -u github.com/alecthomas/gometalinter
gometalinter --install
make: gometalinter: No such file or directory
make: *** [setup] Error 1
$
I figured that is because gometalinter is nowhere in my $PATH, so have added it (I'm using fish-shell):
$ set fish_user_paths /Users/gmile/go/bin
running make setup seem to have succeeded now. This is the output:
$ make setup
go get -u github.com/alecthomas/gometalinter
gometalinter --install
Installing:
aligncheck
deadcode
dupl
errcheck
gas
goconst
gocyclo
goimports
golint
gosimple
gotype
ineffassign
interfacer
lll
megacheck
misspell
safesql
staticcheck
structcheck
unconvert
unparam
unused
varcheck
$
Running make build fails:
$ make build
go build
main.go:11:2: cannot find package"github.com/lucapette/fakedata/pkg/fakedata" in any of:
/usr/local/Cellar/go/1.8.3/libexec/src/github.com/lucapette/fakedata/pkg/fakedata (from $GOROOT)
/Users/gmile/go/src/github.com/lucapette/fakedata/pkg/fakedata (from $GOPATH)
main.go:12:2: cannot find package "github.com/spf13/pflag" in any of:
/usr/local/Cellar/go/1.8.3/libexec/src/github.com/spf13/pflag (from $GOROOT)
/Users/gmile/go/src/github.com/spf13/pflag (from $GOPATH)
make: *** [build] Error 1
$
So either Contributing guideline is incomplete, or I'm missing something obvious about installing and managing go packages.
Your path when cloning the source must be on the golang PATH like :
/home/gujarat/golang/src/github.com/lucapette/fakedata
as you can see my Path to golang path is : /home/gujarat/golang/.
You can also print your golang path in your terminal by entering : $GOPATH.
And the git clone should be in the following the exact as above path : src/github.com/lucapette/.
cd $GOPATH/src/github.com/
mkdir lucaptte
cd lucapette
git clone https://github.com/lucapette/fakedata.git
When you are running the make command which trigger go build this command will look the $GOPATH and your $GOROOT folder.
Your go source should in your gopath - here it is Users/gmile/src. Use go get to fetch the pkg you want to work on instead and it should work.

Resources