K
K
Kolya V2021-09-06 21:07:15
go
Kolya V, 2021-09-06 21:07:15

GoLand does not see the module from import, how to set it up?

Hello.

I open the sources of the legacy project, and GoLand does not understand imports, while the project itself successfully works on production in a container, contact with the author is lost, you are my last hope.

1) If you do that, the package is downloaded to GOPATH (C:\Users\ktokt\go\pkg\mod\github.com\go-chi\[email protected]) 2) GoLand does not see these sources and suggests creating a directory ( "Create Directory github.com at E:/Program Files/Go/src"), 3) Accordingly, the IDE is of no use (an example of an error message: "Cannot resolve symbol 'github.com'"). I think that the problem is in the IDE settings, but I have no idea what exactly. The only recipe JetBrains has seen is to reset the IDE cache and delete the ".idea" directory in the root of the project. Does not help.go get "имя пакета"

61364eb57edc9495756749.jpeg


Included "Index entrie GOPATH", does not help.

Sources on GitHub

set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\ktokt\AppData\Local\go-build
set GOENV=C:\Users\ktokt\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\ktokt\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\ktokt\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=E:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=E:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.17
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\ktokt\AppData\Local\Temp\go-build2159353923=/tmp/go-build -gno-record-gcc-switches

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2021-09-06
@SbWereWolf

So the source code is without modules (no go.mod), and in the latest versions of go, a new way of downloading packages is included by default. In the project, enable modules (go mod init ${package name}) or set the environment variable GO111MODULE=off to download in the old way

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question