安装Golearn包

huangapple go评论100阅读模式
英文:

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/&lt;my_username&gt;/go/pkg/mod/github.com/sjwhitworth/golearn@v0.0.0-20221228163002-74ae077eafb2

sudo go get -t -u -v ./...

答案3

得分: -1

golearn的说明可能有些过时,你可以按照我的步骤进行操作:

  1. 进入一个空文件夹,比如/home/your/code/my_golearn,下面的所有命令都应该在这个文件夹中运行。
  2. 运行go mod init my_golearn来初始化一个Go项目,你将得到一个go.mod文件。
  3. 创建一个main.go文件,并将代码填入其中,代码可以从https://github.com/sjwhitworth/golearn#getting-started获取。
  4. 运行go get github.com/sjwhitworth/golearn
  5. 运行go mod download来获取所有的依赖项。
  6. 运行go get github.com/sjwhitworth/golearn/knn,这可能有些奇怪,但如果缺少这个命令,它将无法正常工作。我认为可能是golearn的开发者在使用go mod时出现了一些错误。
  7. 运行wget https://raw.githubusercontent.com/sjwhitworth/golearn/master/examples/datasets/iris.csv -P datasets来获取所需的数据集。
  8. 运行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:

  1. cd into a empty folder, like /home/your/code/my_golearn, all commands below should be run at this floder
  2. run go mod init my_golearn to init a go project, you will get a go.mod file
  3. create a main.go file and fill it with code from https://github.com/sjwhitworth/golearn#getting-started
  4. run go get github.com/sjwhitworth/golearn
  5. run go mod download to get all dependencies
  6. 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
  7. run wget https://raw.githubusercontent.com/sjwhitworth/golearn/master/examples/datasets/iris.csv -P datasets to get dataset you need
  8. 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

huangapple
  • 本文由 发表于 2021年8月19日 16:05:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/68844126.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定