golangci-lint error go imports error computing diff - go

I´m trying to use golangci-lint with vscode, however when i run it, the following error occurs
level=warning msg="[runner] Can't run linter goanalysis_metalinter: goimports: error computing diff: exec: "diff": executable file not found in %PATH%"
level=error msg="Running error: 1 error occurred:\n\t* can't run linter goanalysis_metalinter: goimports: error computing diff: exec: "diff": executable file not found in %PATH%\n\n"
Does anyone know what do do?

Related

golangci-lint: exec: "git": executable file not found in $PATH

I'm trying to integrate golangci-lint on my project. I use golangci-lint v1.49.0 that I install from snap. I've added ci config on my project but when I try to run it, it throws a very bizarre error.
$ golangci-lint run -v
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 7 linters: [errcheck gosimple govet ineffassign staticcheck typecheck unused]
INFO [loader] Go packages loading at mode 575 (files|name|types_sizes|deps|exports_file|compiled_files|imports) took 805.161254ms
ERRO Running error: context loading failed: failed to load packages: failed to load with go/packages: err: exit status 1: stderr: go: github.com/user/repo#v1.3.4: git init --bare in /home/user/snap/golangci-lint/94/go/pkg/mod/cache/vcs/88980456e822acee6ee17242ca10c17af0281944db0d695e6f13a17951f304ee: exec: "git": executable file not found in $PATH
go: github.com/user/repo#v1.3.4: git init --bare in /home/user/snap/golangci-lint/94/go/pkg/mod/cache/vcs/88980456e822acee6ee17242ca10c17af0281944db0d695e6f13a17951f304ee: exec: "git": executable file not found in $PATH
INFO Memory: 10 samples, avg is 27.8MB, max is 27.8MB
INFO Execution took 809.752753ms
github.com/user/repo isn't a real url, the one I use is private.
These are my config files
# .gitlab-ci.yml
stages:
- test
- build
- sast
- deploy
- cleanup
golangci-lint:
stage: test
image: registry.gitlab.com/gitlab-org/gitlab-build-images:golangci-lint-alpine
script:
- golangci-lint run -v
# .golangci.yml
run:
tests: false
timeout: 10m
skip-dirs:
- "service/mocks"
output:
format: colored-line-number
Why is it unable to read git in $PATH? I've been using git for years using this machine, this is my first time I got an error like this. I also just reinstalled using sudo apt-get install git just to make sure, but it still throws the same error. It looks like Git has already been installed, but it keeps throwing that error.
My OS is Ubuntu v20.04
I've also added the git path by running export PATH=$PATH:/usr/bin/git, but it still keeps throwing the same error.

Encountered an error while running a file through GDB

I'm trying to run a file using GDB but it shows me the following error:
Error creating process C:\Users\Admin\desktop\inctfj\tired, (error 193).

when executing the go get command to install fabric-ca, I'm getting an error

when executing
go get -u github.com/hyperledger/fabric-ca/cmd/
from the fabric-ca guide, I get the following error:
# cd /home/pi/go/src/github.com/hyperledger/fabric-ca; git pull --ff-only
error: cannot open .git/FETCH_HEAD: Permission denied
package github.com/hyperledger/fabric-ca/cmd: exit status 1`
I tried git cloning and it downloaded everything from the fabric-ca repository, then I tried installing fabric-server and client by myself like this:
sudo make fabric-ca-server
this also produced the following error:
Building fabric-ca-server in bin directory ...
/bin/sh: 1: go: not found
Makefile:91: recipe for target 'bin/fabric-ca-server' failed
make: *** [bin/fabric-ca-server] Error 127
Looks like your GOPATH is set to /home/pi/go and appears that you do not have access to somewhere along the path to /home/pi/go/src/github.com/hyperledger/fabric-ca.
I'd check make sure that the user you are running go get with has R/W access to /home/pi/go/src

Permission denied for protoc on maven build in Teamcity

I am trying to build a project using maven on teamcity and getting this error during maven build step.
[Step 2/4] [ERROR] protoc failed output:
[Step 2/4] [ERROR] protoc failed error: /bin/sh: 1: protoc: Permission denied
[Step 2/4] [13:03:14][Step 2/4] Failed to execute goal
com.google.protobuf.tools:maven-protoc-plugin:0.1.10:compile
(generate-sources) on project unit-protocol-lib: protoc did not exit
cleanly. Review output for more information.
Keep in mind I am using docker-compose for building the teamcity agent (agent running in container) and protoc is added to /usr/local/bin/protoc ($PATH has /usr/local/bin, /usr/local/bin/protoc has rwx permissions).
EDITED for ease
Forget everything above for a while.
I logged into the buildagent of teamcity server, access the shell using /bin/sh and execute the command protoc and it returns the error:
protoc failed error: /bin/sh: 1: protoc: Permission denied
Any help??
I had the same issue.
What I found was that the error message was misleading.
Here's what worked for me:
Try this:
protoc ./proto/hello/hello.proto --go_out=plugins=grpc:./outputDirectory -I ./proto/hello/hello.proto
Parts of the command obviously look redundant, but this was what I had to do to get it working. I recommend trying this, and see if it runs. If it does then you can see if you're able to tweak it, but I don't think so.
if "." is your output, then do this:
protoc ./proto/hello/hello.proto --go_out=plugins=grpc:. -I ./proto/hello/hello.proto
Notice that you don't need space.
Answer from the future (for someone like me who ran into this problem).
In folder with project in cmd:
chmod +x ./proto-gen.sh

Install external package in Google Go

I was trying to install external packages in GO language. I've found many external packages at http://godashboard.appspot.com/package.
I am working on windows system.
I tried this command to install go-router package.
goinstall go-router.googlecode.com/svn/trunk
This resulted in following error....
C:\cygwin\bin\bash.exe: === cd c:\go\src\pkg\go-router.googlecode.com\svn\trunk;
bash gomake -f- install
/cygdrive/c/go/bin/gomake: line 3: exec: make: not found
--- exit status 127
goinstall: go-router.googlecode.com/svn/trunk: install: running bash: exit status 127
I am unable to find out the reason for the error and the meaning of status code. I've read the goinstall command description but no luck..
It seems make command is missing. Make sure it's installed and that PATH variable is defined correctly.

Resources