英文:
Installing package Golearn
问题
我正在尝试安装Golearn包,按照这些说明进行操作。
在终端中运行以下命令:
go get -t -u -v github.com/sjwhitworth/golearn
然后我尝试运行(按照要求):
cd $GOPATH/src/github.com/sjwhitworth/golearn
然而,bash找不到该目录。我应该怎么办?(我正在使用Linux)
英文:
I'm try to install the package Golearn, following these instructions.
After running in the terminal
go get -t -u -v github.com/sjwhitworth/golearn
I tried to run (as required):
cd $GOPATH/src/github.com/sjwhitworth/golearn
However bash doesn't find this directory. What should I do?
(I'm using linux)
答案1
得分: 2
安装Golearn包
在/home/name/tmp/目录下进行示例构建:
git clone https://github.com/sjwhitworth/golearn.git
cd golearn/
## 完成安装
## 运行以下命令完成安装
go get -t -u -v ./...
使用:请(也)阅读README.md文本文件。
英文:
> install the package Golearn
Example build, in /home/name/tmp/
git clone https://github.com/sjwhitworth/golearn.git
cd golearn/
## Completing the installation
## Run the following to complete installation
go get -t -u -v ./...
Using : Please (also) read the text file README.md .
答案2
得分: 1
我做了以下操作并成功了:
go get -t -u -v github.com/sjwhitworth/golearn
go: 正在下载 github.com/sjwhitworth/golearn v0.0.0-20221228163002-74ae077eafb2
go: 已添加 github.com/sjwhitworth/golearn v0.0.0-20221228163002-74ae077eafb
go env GOPATH
/Users/<my_username>/go
cd /Users/<my_username>/go/pkg/mod/github.com/sjwhitworth/golearn@v0.0.0-20221228163002-74ae077eafb2
sudo go get -t -u -v ./...
英文:
I did the following and worked:
go get -t -u -v github.com/sjwhitworth/golearn
> go: downloading github.com/sjwhitworth/golearn v0.0.0-20221228163002-74ae077eafb2
go: added github.com/sjwhitworth/golearn v0.0.0-20221228163002-74ae077eafb
go env GOPATH
> /Users/<my_username>/go
cd /Users/<my_username>/go/pkg/mod/github.com/sjwhitworth/golearn@v0.0.0-20221228163002-74ae077eafb2
sudo go get -t -u -v ./...
答案3
得分: -1
golearn的说明可能有些过时,你可以按照我的步骤进行操作:
- 进入一个空文件夹,比如
/home/your/code/my_golearn
,下面的所有命令都应该在这个文件夹中运行。 - 运行
go mod init my_golearn
来初始化一个Go项目,你将得到一个go.mod
文件。 - 创建一个
main.go
文件,并将代码填入其中,代码可以从https://github.com/sjwhitworth/golearn#getting-started获取。 - 运行
go get github.com/sjwhitworth/golearn
。 - 运行
go mod download
来获取所有的依赖项。 - 运行
go get github.com/sjwhitworth/golearn/knn
,这可能有些奇怪,但如果缺少这个命令,它将无法正常工作。我认为可能是golearn的开发者在使用go mod时出现了一些错误。 - 运行
wget https://raw.githubusercontent.com/sjwhitworth/golearn/master/examples/datasets/iris.csv -P datasets
来获取所需的数据集。 - 运行
go run ./main.go
,你将得到与https://github.com/sjwhitworth/golearn#getting-started相同的结果。
如果你对如何在现代的Go项目中安装依赖项不熟悉,最好阅读https://go.dev/blog/using-go-modules。
英文:
The instruction of golearn maybe some outdated, you can follow my process:
cd
into a empty folder, like/home/your/code/my_golearn
, all commands below should be run at this floder- run
go mod init my_golearn
to init a go project, you will get ago.mod
file - create a
main.go
file and fill it with code from https://github.com/sjwhitworth/golearn#getting-started - run
go get github.com/sjwhitworth/golearn
- run
go mod download
to get all dependencies - run
go get github.com/sjwhitworth/golearn/knn
, it's strange, but it doesn't work if this command miss, I think maybe the developer of golearn has some misuse of go mod - run
wget https://raw.githubusercontent.com/sjwhitworth/golearn/master/examples/datasets/iris.csv -P datasets
to get dataset you need - run
go run ./main.go
, you will get result same as https://github.com/sjwhitworth/golearn#getting-started
If you are not familiar with how to install dependency in a modern go project, it's better for you to go through https://go.dev/blog/using-go-modules
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论