102 questions
0
votes
1
answer
38
views
how to change GOPATH in vs code?
if you enter the command "go evn" in vs, it shows that GOPATH=C:\Users\user\go.
if I want to change GOPATH in vs code, how do I do it?
The book I'm reading says: set GOPATH="C:\code&...
0
votes
1
answer
217
views
Do you need to use a separate $GOPATH between Windows and WSL?
I use Windows and WSL for developing Go code, but, don't know if I need to have a separate $GOPATH for Windows and WSL, or if I can use the same $GOPATH for both.
Can you use the same $GOPATH between ...
0
votes
1
answer
461
views
Why does `go mod` take up space on another disk than my GOPATH?
I'm trying to build a completely new project in order to run some unit tests. I'm using Windows + WSL.
When I try to run the tests, obviously first it takes the go.mod file and starts downloading all ...
0
votes
1
answer
1k
views
go.mod vs GOPATH
I am currently migrating from GOPATH to go.mod. However, I cannot understand this:
I read everywhere that GOPATH and go.mod does not mix, either this or that
but then the go modules use GOPATH to ...
2
votes
3
answers
1k
views
hyperledger fabric - "go": executable file not found in $PATH
I 'm new to Hyperleger Fabric and trying to done examples from Using the Fabric test network documentation. I'm stuck on the phase of starting a chaincode on the channel. I am getting error located ...
1
vote
0
answers
609
views
How to ignore a directory or a file while running goimports?
I have the following project structure
proejct/
├── README.md
├── go.mod
├── go.sum
├── src
│ ├── delivery
│ │ ├── grpc
│ │ │ ├── index.go
│ │ │ ├── pb
│ │ │ │ ├── project.pb....
1
vote
1
answer
409
views
Building go/src packages from golang/go Github Repository
Asking to see what the appropriate workaround is for building individual go packages from the go/std library when working on a github repo fork. The issue encountered is summarized by the following ...
3
votes
2
answers
2k
views
Not able to watch go files after installing Compile Daemon
Installed using, go get github.com/githubnemo/CompileDaemon and go install github.com/githubnemo/CompileDaemon
When I try to run it using -> CompileDaemon --compile="./folderName"
It ...
0
votes
2
answers
2k
views
How to fix wrong variables "go env GOROOT"?
I made a mistake:
go env -w GOROOT=/Users/apple/Documents/testProject/GXB_be:/usr/local/go
I set a wrong path as a variable of go env.
This makes it almost impossible for me to use the go env command ...
0
votes
1
answer
525
views
Go: Cannot find package in any of Vendor Tree, $GOROOT or $GOPATH even though a private package exists in Vendor Tree
Here's my project structure:
Here's my mod file:
module github.com/bloodcompany/blood-microservices/stores/sync-stores-google-sheet-to-firestore
go 1.16
require (
cloud.google.com/go/firestore ...
0
votes
0
answers
3k
views
Build Error: GOPATH set to GOROOT (C:\Users\Admin\go) has no effect, cannot find main module
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
Its my first code, but ended up with this error, I tried many times to resolve issues like this in ...
0
votes
1
answer
2k
views
GO env variable PATH got messed up
I am trying to install package using go with below command:
go install fyne.io/fyne/v2/cmd/fyne@latest
This is the same as what the instruction said but ideally it should return below message
Users/...
2
votes
1
answer
5k
views
When should you set the $GOPATH variable? [duplicate]
Can anyone explain when to set $GOPATH? I know it's in the default, C:\Users\Username\go, location, but what if all my coding projects live in Z:<codelocation> ?
2
votes
0
answers
690
views
vim-go: permission denied installing 'gopls'
I'm trying to setup the vim-go in a work environment but I don't have permission to install the gopls using:
GoInstallBinaris
or
go get golang.org/x/tools/gopls@latest
I'm getting this: /path/go/bin/...
-3
votes
2
answers
5k
views
Can't import a Go module
I'm learning Go ad I'm trying to build go file:
package main
import (
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"net/http"
)
func ...
1
vote
1
answer
459
views
Go server not showing IntelliSense of internal imports
I'm using golang and GoLand(Jetbrains)IDE for development on UBUNTU. My Go path is /usr/local/go and my Project Directory is at /Home/GoLandProjects with bin, src, pkg directories and my project ...
1
vote
1
answer
650
views
GOPATH/GOROOT setup for Hyperledger fabric chaincode
I have done basic setup in Hyperledger Fabric 1.4.7 and made all peer's to join the channel. After exploring chaincode in golang, I started trying chaincode install command and I was facing issue's in ...
-5
votes
2
answers
2k
views
GOPATH entry is relative must be Absolut path ,How can solve it
go: GOPATH entry is relative; must be absolute path: "%Jittu%\go".
For more details see: 'go help gopath
-1
votes
1
answer
786
views
Trouble with using gorilla/mux package in mac
I am trying to learn how to build a webserver using go and mux. I am importing mux to the main.go file as import github.com/gorilla/mux. However, when I am trying to run the code. I get the following ...
0
votes
2
answers
3k
views
How to solve the import-local-package problem: GOPATH is ignored, only GOROOT takes effects
I'm new in GO and has got stuck in environment configuration for hours.
I succeeded to run some test projects, but when I tried to import my custom local packages (say xxx), the "go run" ...
12
votes
4
answers
41k
views
Go error: go : go.mod file not found in current directory or any parent directory; (working on GOPATH/src)
I installed Golang and faced with go.mod file not found in current directory or any parent directory error at very first time.
But I'm working on <GOPATH>/src directory. Isn't go.mod only ...
0
votes
1
answer
261
views
Flutter desktop 'hover' can not be recognised
I am trying to run my flutter app on desktop with hover.
I ran this command to install hover
go get -u github.com/go-flutter-desktop/hover
I have GO installed and the command above finishes the ...
0
votes
1
answer
5k
views
How to update the GOPATH for VS Code Go extension tools?
My $GOPATH is /home/shambhav/code_mis/golang(current gopath), but long ago when I was setting up GO, I messed it up and GOPATH was /home/shambhav/home/shambhav/code_mis/golang(previous gopath). I ...
0
votes
1
answer
1k
views
go build not looking in $GOPATH
I have set $GOPATH, and importing some part of my source code which is present in $GOPATH/src.
Package I need to import is written by me and stored in GOPATH/src
I have named it as otelkafkago and it'...
0
votes
3
answers
2k
views
Problem in setting the value of GOPATH on windows machine
My GOROOT path :-
C:\Go
I have set GOPATH to :-
C:\Users\kunal\go
But when I import modules (like github.com/gorilla/mux) inside VS Code. VS Code prompts me this error :-
could not import github.com/...
1
vote
1
answer
136
views
What is $GOPATH[i] and $GOPATH[d]?
A section of the Go Modules Reference describes some rules for minimal module compatibility. There is a list of conditions in this section and two of them look like this:
No $GOPATH[i]/src/$modpath/$...
2
votes
2
answers
1k
views
How to config a simple Go project
I'm trying to follow the Writing an intepreter in Go book, by Thorsten Ball, and in the first chapter he establish this simple scheme
file /Users/myuser/projects/monkey/token/token.go
file /Users/...
-2
votes
1
answer
2k
views
Can I set the GOPATH using the go command line tool?
I would like to set GOPATH using the go tool upon compilation, just like adding an include path in C/++. I want the gopath to be used only within a certain project. Can this be done without setting an ...
12
votes
2
answers
18k
views
Is there a way to run a Go module from another directory
I have the following project structure, outside of GOPATH.
. // Project root
├── Dockerfile
├── .env
├── README.md
└── src
├── main.go
├── go.mod
├── go.sum
├── internal
│ ├── ...
-1
votes
1
answer
2k
views
golang compile simple app module not found (GOPATH?)
just started with go, got stuck on a very simple application (from here https://golang.org/doc/tutorial/call-module-code)
when I try to compile the hello.go:
...
hello.go:6:5: cannot find module ...
1
vote
1
answer
506
views
Difficulty installing go buffalo using go mod on windows
I am very new to golang. I am trying to work with the gomod. Trying to explore the go buffalo framework. But finding a bit of difficulty in installing that.
What I have done:
I saw that go get is ...
3
votes
2
answers
4k
views
Golang Module problem--package xxx/xxxx is not in GOROOT
so here is what my directory is:
go
|-src
|-ppppppSample
|-newFolderOne
|-firstSample.go
|-hello.go
|-go.mod
and here is the content of hello.go
package main
...
-1
votes
2
answers
1k
views
Use GOPATH in golang makefile or init go mod first?
I'm learning to write Golang makefile and got some confused me because some examples they config GO env such as GOOS, GOPATH, GOBASE before building. But normally I can use go mod init to create go ...
20
votes
1
answer
11k
views
removing module path in trace in go
I need to remove absolute path in the trace, that corresponds to the imported module. Even though I compile my program so: go build -gcflags=-trimpath=$GOPATH -asmflags=-trimpath=$GOPATH I still get ...
3
votes
3
answers
4k
views
spf13/cobra can't download binary to $GOPATH/bin
I want to use spf13/cobra on my project.
spf13/cobra: A Commander for modern Go CLI interactions
typed install command result
$ go get -u github.com/spf13/cobra/cobra
go: downloading github.com/spf13/...
0
votes
1
answer
12k
views
Go install copying permission denied
When running go install on my cmd folder I get the error:
go install cmd/go: copying
/var/folders/wh/9y99138n2w1bvcwxz3tbb8zw0000g
n/T/go-build195667123/b150/exe/a.out: open
/usr/local/go/bin/go: ...
3
votes
1
answer
4k
views
How to make go search for packages in GOPATH while importing a package?
package main
import (
"fmt"
"controller/userhandler" //not able to import this custom package
"github.com/gin-gonic/gin" ...
1
vote
1
answer
5k
views
go env shows the GOPATH do not match
I use go env to check the GOPATH:
$ go env
GOARCH="amd64"
GOBIN="/usr/local/Cellar/go/1.7.6/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS=&...
0
votes
1
answer
203
views
Go pkg/mod vs pkg/windowsamd_64 on go build
I am beginner in go and facing difficulty in understanding go/pkg folder.As suggested by documentation it contains pkg/mod and pkg/windowsamd_64. pkg/windowsamd_64 for storing compiled files. What ...
1
vote
0
answers
197
views
Unexpected directory layout after moving project into new directory
I was working on a Go project in a directory that was not in my GOPATH. I was using relative imports.
I am trying to move the project into my GOPATH so I can stop using relative imports, but I keep ...
1
vote
1
answer
7k
views
VS Code: module and GOPATH usage and settings
I recently rearranged my VS Code workspace. Before rearranging it I had no problems neither with Go modules nor $GOPATH. Now I have adopted the much beloved hexagonal project layout as I find it quite ...
-1
votes
2
answers
1k
views
Cannot use Go Commands of go libraries. [$GOBIN or $GOPATH problem, Windows]
When I get go libraries from github, I can use them in code. But I cannot use their commands. For example, after "go get annie", I try to use its command, e.g."annie bebe.be/be/bebe". But I get "The ...
13
votes
4
answers
30k
views
Cannot do any go command anymore
Before it happened, what I am doing is trying to use the dep to manage my golang code dependency.
What I found right now is I cannot do any command with go, even if I try to uninstall it with brew by ...
-1
votes
1
answer
1k
views
When running go env GOPATH is shown as something different than what I have set in my environment variables?
First of all I'm really new to Go. I've been struggling with this issue for about a week now and its driving me crazy (because of this issue its not recognizing my packages). I have set up my GOPATH ...
0
votes
1
answer
2k
views
Installing gota package in go workspace
I'm writing this away from my code so fingers crossed.
I've recently started learning Go from a Python background. I've set up my workspace (Linux Mint OS) so:
GOPATH=$HOME/go
GOROOT=/usr/local/go
...
0
votes
1
answer
48
views
How to distinct what dependencies are downloadable?
I use this code to get a list of dependencies imported in a single Go source file:
// GetFileImports returns all the imports from the Golang source code file.
func GetFileImports(filepath string) ([]...
5
votes
2
answers
6k
views
GOPATH environment variable not getting set in the Fish shell?
I have a ~/.config/fish/config.fish which contains the following lines:
set PATH $PATH (go env GOPATH)/bin
set -x GOPATH (go env GOPATH)
If I simply run go env GOPATH at the command line, I get the ...
-1
votes
2
answers
1k
views
installed 'go1.13.3.darwin-amd64.pkg' on mac os. Set GOPATH, PATH, GOROOT env variables. But Go doestn't seem to be installed
I installed go1.13.3.darwin-amd64.pkg on Mac. I set env variables in ~/.bash_profile
GOPATH = $HOME/gocode
GOROOT = /usr/local/go
PATH = $PATH:$GOPATH/bin
saved the edits with source /....
2
votes
2
answers
4k
views
Installing a package to GOPATH in directory with go.mod
I would like to install a package to GOPATH using go get. This became tricky with go tooling migrated to go mod support.
There is no problem outside of the project directory (=directory with go.mod ...
4
votes
3
answers
5k
views
How to find a Go package installed with 'go get -u' when no $GOPATH is defined?
I'm following the gRPC Quickstart tutorial for Go, https://grpc.io/docs/quickstart/go/, and have installed gRPC using the command
go get -u google.golang.org/grpc
I actually haven't defined a GOPATH ...