Module lookup disabled by GOPROXY=off golangci - go

I have a vendor folder and CI/CD task Linter. Before push the folder to gitlab I did
go mod tidy
go mod vendor
My Linter task in Makefile looks like
#GO111MODULE=on GOFLAGS=-mod=vendor GOPROXY=off $(GOLINT) run ./... -v --max-same-issues 0
and I have no any problems when I start linting locally. But during CI/CD I got an error
Running error: context loading failed: failed to load packages: failed
to load with go/packages: err: exit status 1: stderr: go:
github.com/jmoiron/sqlx#v1.3.1: module lookup disabled by GOPROXY=off
So i can't understand why I got this error
Update
I decided to remove the vendor, go.mod and go.sum. Then I created new go.mod and did
go mod vendor
After that I got the same error but with another package
level=error msg="Running error: context loading failed: failed to load
packages: failed to load with go/packages: err: exit status 1: stderr:
go: github.com/fsnotify/fsnotify#v1.5.1: module lookup disabled by
GOPROXY=off

The problem was in the settings of golangci modules-download-mode
this solution is set this variable to vendor mode:
modules-download-mode: vendor

Related

Exporting dependencies from package which is existing vendor

I am new to golang and glide dependency management tool. I am trying to run glide install in created my company project. I have met an error about go-xorm library.
[ERROR] Update failed for github.com/go-xorm/xorm: Unable to get repository: Cloning into '/Users/xxx/.glide/cache/src/https-github.com-go-xorm-xorm'...
remote: Repository `go-xorm/xorm' is disabled.
remote: Please ask the owner to check their account.
fatal: unable to access 'https://github.com/go-xorm/xorm/': The requested URL returned error: 403
: exit status 128
[ERROR] Failed to checkout packages: Unable to get repository: Cloning into '/Users/xxx/.glide/cache/src/https-github.com-go-xorm-xorm'...
remote: Repository `go-xorm/xorm' is disabled.
remote: Please ask the owner to check their account.
fatal: unable to access 'https://github.com/go-xorm/xorm/': The requested URL returned error: 403
: exit status 128
It's seem that I am not able to download it from github because the owner made it disabled to clone.
How can I fix this error or Is there any way to export directly from local vendor without fetching from github. I am sure that the package is already on my local vendor folder. Thank you so much!!!
This is because XORM moved from Github (repo is still available as Public Archive) to Gitea and instead of github.com/go-xorm/xorm they now use xorm.io/xorm.
I'd recommend to stop using glide completely and replace it with Go Modules based workflow; but if you must use it, you will need to remove github.com/go-xorm/xorm from your glide.yaml, add xorm.io/xorm (you can use glide get to do so) and fix your imports everywhere in codebase.

Using golang-ci lint error fetch corp package

Im using golangci-lint and getting the following error in CI, any idea what could be the reason? and how can I avoid this.
Our GitHub repo is already have all the vendor packages so it shouldn't install it in first place.
golangci-lint run --config golangci.yml
level=error msg="Running error: context loading failed: failed to load packages: failed to load with go/packages: err: exit
status 1: stderr: go: github.avt.corp/ding/logger-ut#v1.1.0:
unrecognized import path "github.avt.corp/ding/logger-ut" (https
fetch: Get https://github.avt.corp/ding/logger-ut?go-get=1: x509:
certificate signed by unknown authority)\n"
btw I was able to clone the project and run it
Use the following:
run:
modules-download-mode: vendor
or add this to the command you are runnig
--modules-download-mode vendor

The command "go get github.com/gohugoio/hugo" failed and exited with 2 during

I am building websites with Hugo and deploying using Travis-Ci. Recently (about within 3 days) an error occurred:
$ go get github.com/gohugoio/hugo
# github.com/gohugoio/hugo/tpl/internal/go_templates/fmtsort
../../gohugoio/hugo/tpl/internal/go_templates/fmtsort/sort.go:58:18: mapValue.MapRange undefined (type reflect.Value has no field or method MapRange)
The command "go get github.com/gohugoio/hugo" failed and exited with 2 during .
Since the code errored at go get line, I think it must be caused by some updates by Hugo.
.travis.yml
sudo: false
language: go
git:
depth: 1
install:
- go get github.com/gohugoio/hugo
script:
- git submodule init
- git submodule update
- hugo
# Deploy to GitHub pages
deploy:
provider: pages
skip_cleanup: true
github_token: $GITHUB_TOKEN
local_dir: public
on:
branch: master
Since Hugo 0.48, Hugo uses the Go Modules support built into Go 1.11 to build.
docker run -it golang:1.10
root#2598ed7e489d: go get github.com/gohugoio/hugo
src/github.com/gohugoio/hugo/tpl/internal/go_templates/fmtsort/sort.go:58:18: mapValue.MapRange undefined (type reflect.Value has no field or method MapRange)
docker run -it golang:1.11
root#07e6e634656a: go get https://github.com/gohugoio/hugo
will not return any error
using go versions > 1.11 will not cause this issue.
In example 1,similar error is there.
In example 2,it is installed successfully.

Gitlab CI and Go modules

I have a Go project and I want write a Gitlab CI file my project but I see error loading module requirements. This is my gitlab CI file:
stages:
- compile
build:
stage: compile
image: golang:1.12
script:
- go build -o binary
error :
Running with gitlab-runner 11.8.0 (4745a6f3)
on Runner #6 e0e0c446
Using Docker executor with image golang:1.12 ...
Pulling docker image golang:1.12 ...
Using docker image sha256:be63d15101cb68aea1841b45201b08a1a486c1a60a029bbf0ddb284ab646b0b7 for golang:1.12 ...
Running on runner-e0e0c446-project-753-concurrent-0 via runner-01.tool.afra.snapp.infra...
Cloning repository...
Cloning into '/builds/Alsopa/echo-training'...
Checking out ab3994cc as develop...
Skipping Git submodules setup
$ go build -o binary
go: finding github.com/labstack/gommon v0.2.9
go: finding github.com/labstack/echo v3.3.10+incompatible
go: finding github.com/go-sql-driver/mysql v1.4.1
go: google.golang.org/appengine#v1.6.1: unrecognized import path "google.golang.org/appengine" (parse https://google.golang.org/appengine?go-get=1: no go-import meta tags ())
go: error loading module requirements
ERROR: Job failed: exit code 1
Be sure you upload the last go.sum file. Just before uploading to master for the ci execution run go get, upload to master and run the ci.
The primary error seems to be:
go: google.golang.org/appengine#v1.6.1: unrecognized import path
"google.golang.org/appengine" (parse
https://google.golang.org/appengine?go-get=1: no go-import meta tags ())
I would try running go get -v google.golang.org/appengine and curl -v https://google.golang.org/appengine?go-get=1 from within your CI environment to see what they show.
This is what I get for go get -v google.golang.org/appengine:
$ go get -v google.golang.org/appengine
Fetching https://google.golang.org/appengine?go-get=1
Parsing meta tags from https://google.golang.org/appengine?go-get=1 (status code 200)
get "google.golang.org/appengine": found meta tag
get.metaImport{Prefix:"google.golang.org/appengine",
VCS:"git", RepoRoot:"https://github.com/golang/appengine"}
at https://google.golang.org/appengine?go-get=1
Perhaps you have some network connectivity, firewall, or HTTP proxy issue.
You should download modules before compilation. Assuming your project already has go modules files go.mod and go.sum try to update .gitlab-ci.yml this way
build:
stage: compile
image: golang:1.13
script:
- go get -d -v
- go build -o binary

Haskell on Windows - Stack fails to fetch package index

I'm trying to install Haskell on Windows. Downloaded the installer and just clicked through everything, then tried to use Stack to install a package, ran it from a temporary folder in which everything has write access:
C:\t>stack install hfmt
Using latest snapshot resolver: lts-8.3
Writing implicit global project config file to: C:\sr\global-project\stack.yaml
Note: You can change the snapshot via the resolver field there.
Downloaded lts-8.3 build plan.
Fetching package index ...=.git""=="gui" was unexpected at this time.
C:\sr\indices\Hackage\git-update\all-cabal-hashes>#if ""--git-dir=.git""=="gui" #goto gui
Process exited with ExitFailure 255: C:\Program Files (x86)\Git\cmd\git.CMD --git-dir=.git fetch --tags
Failed to fetch package index, retrying.
removeDirectoryRecursive: permission denied (Access is denied.)
What's going wrong, and how can I fix it? Or should I forget about Stack and just use Cabal instead?
Tried rerunning the command as administrator. This time the response was instant:
C:\t>stack install hfmt
Fetching package index ...=.git""=="gui" was unexpected at this time.
C:\sr\indices\Hackage\git-update\all-cabal-hashes>#if ""--git-dir=.git""=="gui" #goto gui
Process exited with ExitFailure 255: C:\Program Files (x86)\Git\cmd\git.CMD --git-dir=.git fetch --tags
Failed to fetch package index, retrying.
removeDirectoryRecursive: permission denied (Access is denied.)

Resources