zishang520/socket.io

怎么添加这个库为依赖

Closed this issue · 5 comments

vipcxj commented

如题,刚开始用go不久,go挺奇怪的,go.mod里完全没模板的版本信息,也不知道版本信息存哪里~ 我看了这个项目的go.mod,发现模块名是github.com/zishang520/socket.io/v2
于是我就执行了

go get github.com/zishang520/socket.io/v2

安装确实是安装了,require里多了github.com/zishang520/socket.io/v2,问题是只多了这一条~ 我安装其他第三方依赖时,间接依赖都是会自动加上的,但只有这个项目,就只装了本身~ 是我命令输错了吗?

Hello, it's great to receive your inquiry. Regarding your question, I have the following two points to address:

  1. How to use ·go mod?
    For information on how to use go.mod, please refer to: https://go.dev/ref/mod. Generally, once we have implemented go mod, there is no need to use the outdated go get.

  2. How to add this library as a dependency?
    a. If you are using go mod, you just need to import the relevant package/module in your Go code. Golang will automatically load the relevant dependencies when compiling the program. Of course, you can also manually pull relevant dependency information into the go.mod and go.sum files by using the go mod tidy command.

    b. If you are not using go mod, then you need to use go get to install all the relevant dependencies. This ensures that Golang can compile the files correctly.


您好,很高兴收到您的询问。 关于你的问题,我有以下两点需要解答:

  1. 如何使用 go mod
    有关如何使用 go mod 的信息,请参阅:https://go.dev/ref/mod。 一般来说,一旦我们实现了go mod,就没有必要再使用过时的go get了。

  2. 如何将此库添加为依赖项?
    a. 如果您使用 go mod,则只需在 Go 代码中导入相关的包/模块即可。 Golang在编译程序时会自动加载相关依赖。 当然,您也可以使用 go mod tidy 命令手动将相关依赖信息拉取到 go.modgo.sum 文件中。
    b. 如果您没有使用 go mod,那么您需要使用 go get 安装所有相关依赖项。 这确保了 Golang 可以正确编译文件。

vipcxj commented

@zishang520 我发现问题所在了~
我在 https://pkg.go.dev/ 上搜到了你的库,然后发现你这库的完整名字应该是这个:

socket (github.com/zishang520/socket.io/v2/socket)

然后我是用

go get github.com/zishang520/socket.io/v2/socket

(注意末尾这个socket)
这次就正常了,间接依赖也正常一起加上了

虽然或许像你说的可以不用go get,但这个小问题确实会让库的使用者很迷惑~

Yes, you are right. There is no information in the root directory. For better readability and maintainability, the package has been divided into various subdirectories.


是的,你是对的。 根目录下没有任何信息。 为了更好的可读性和可维护性,该包已分为各个子目录。

If you read the readme.md file, you will get more help.


如果您阅读 readme.md 文件,您将获得更多帮助。

If there are no other questions I will close this issue.