K
K
Ken Jee2017-07-16 19:56:12
go
Ken Jee, 2017-07-16 19:56:12

How to properly set up paths for Golang on Windows?

OS: Windows 10
IDE: Gogland
Installed the Golang SDK in C:\Go . I decided to try to code something in order to learn the language. I took an example from the Internet on the topic of a small bot for Telegram. There, in the example, it says that you need to install the Syfaro/telegram-bot-api package :
$ go get github.com/Syfaro/telegram-bot-api
Installed ... It seems ... No errors fell out during the installation ... Yes, nothing fell out at all. The go get command worked silently. But inside the SDK, the required package did not appear. Launching the application crashes with the following error:

"C:\Program Files\JetBrains\Gogland 171.4694.61\bin\runnerw.exe" C:\Go\bin\go.exe run E:/Proj/main.go
src\bot.go:4:2: cannot find package "github.com/Syfaro/telegram-bot-api" in any of:
  C:\Go\src\github.com\Syfaro\telegram-bot-api (from $GOROOT)
  C:\Go\bin\src\github.com\Syfaro\telegram-bot-api (from $GOPATH)

Process finished with exit code 1

My go env:
$ go env
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:/Users/Мачез/gocode
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set PKG_CONFIG=pkg-config
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2

As I understand it, the problem still lies in the $GOPATH and $GOROOT variables ? How to set them up for Windows? Judging by go env, everything seems to be normal

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Michael, 2017-07-17
@Singaporian

Imagine for a second that you have 5 projects and three of them use the same library but different versions. How do you put three libraries of different versions in one GOPATH?
That's exactly why dependency management was invented. The best one for today (and this is not IMHO!) is gb . It will put the dependencies in the vendor directory of the specific project.

S
stoitli, 2017-07-21
@stoitli

ONLY one variable is enough - GOPATH.
It is possible that they do not like Russian letters in this way.

V
Vitaly Filinkov, 2017-07-16
@vitfil

Here is everything!

A
Alexander Pavlyuk, 2017-07-17
@pav5000

Judging by go env, you have GOPATH=C:/Users/Мачез/gocode
But for some reason Gogland thinks that $GOPATH is in everything here: C:\Go\bin
Perhaps you told him so when creating the project. Tell Gogland you have $GOPATHC:/Users/Мачез/gocode

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question