简体   繁体   English

如何修复 $GOPATH/go.mod 存在但不应该存在 - Linux Fedora

[英]How do I fix $GOPATH/go.mod exists but should not - Linux Fedora

I am new to Golang, I am following this tutorial https://golang.org/doc/tutorial/getting-started but for some reason I keep getting this message every time I try to run the code:我是 Golang 的新手,我正在关注本教程https://golang.org/doc/tutorial/getting-started但由于某种原因,我每次尝试运行代码时都会收到此消息:

$GOPATH/go.mod exists but should not

I have tried to look at answers like this one: https://stackoverflow.com/a/62062562/9785222 but I dont understand what is GOPATH and where is it.我试图查看这样的答案: https://stackoverflow.com/a/62062562/9785222但我不明白什么是 GOPATH 以及它在哪里。

I am using Vi as an editor on Linix Fedora我在 Linix Fedora 上使用 Vi 作为编辑器

GOPATH defaults to $HOME/go on Unix. GOPATH在 Unix 上默认为 $HOME/go。

Remove the file $HOME/go/go.mod or explicitly set $GOPATH to a different directory.删除文件 $HOME/go/go.mod 或将 $GOPATH 显式设置为不同的目录。

$GOPATH should point out to the src directory, in my case in Debian, I set $GOPATH to /usr/local/go/src and the problem was solved. $GOPATH应该指向src目录,在我的情况下,在 Debian 中,我将$GOPATH设置为/usr/local/go/src并解决了问题。

export $GOPATH=/usr/local/go/src

What is GOPATH ?什么是 GOPATH?

GOPATH is a variable that defines a folder, under which GO expects our code to reside . GOPATH 是一个定义文件夹的变量, GO期望我们的代码驻留在该文件夹下。 For more details, you can check this link有关更多详细信息,您可以查看此链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Is go.mod in Go the same thing as package.json in JavaScript (node)? - Is go.mod in Go the same thing as package.json in JavaScript (node)? 错误信息:go: go.mod 文件在当前目录或任何父目录中找不到; - Error Message : go: go.mod file not found in current directory or any parent directory; Go 包含 Typescript AWS-CDK 目录的项目杂乱无章 go.mod 文件 - Go project containing Typescript AWS-CDK directory has cluttered go.mod file 如何将 function 从另一个目录连接到 Go/Echo? - How do I connect a function from another directory to Go/Echo? 如何检查集合中是否存在文档 (Firebase REACT)? - How do I check if a document exists within a collection (Firebase REACT)? 如何使用 IMAP 使用 GO 在 Gmail 中创建草稿 - How do I create a draft in Gmail using IMAP using GO 如何修复变异运算符不是可变错误? - How do i fix mutating operator isn't mutable error? 如何使用 Firebase 主机修复被阻止的 CORS? - How do I fix Blocked CORS with Firebase Hosting? Azure:如何解决创建服务原则时出现的错误? - Azure: How do I fix this Error when Creating Service Principle? Go Mod 在Raspberry Pi4上下载 - Go Mod Download on Raspberry Pi4
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM