英文:
How can I import a library from github to GO playground?
问题
你好,我想在GO Playground中导入一个第三方库,我看到了一个关于这个问题的答案:https://stackoverflow.com/a/27813778/6638204,但是它说这是不可能的,但是在GitHub上的xiam/go-playground库中表示可以做到这一点。我尝试使用它,但是我不明白我应该做什么。我成功安装了该库,并使用它运行了不需要第三方库的程序,但是我不知道如何导入第三方库。附注:我在我的机器上安装了Docker。
英文:
Hi I want to import a 3rd party library to GO playground, I saw an answer for this question: https://stackoverflow.com/a/27813778/6638204 but it said that this can not be done, but the xiam/go-playground library on github states that it can do this. I tried using it but I did not understand what should I exactly do. I successfully installed the library and used it to run programs that do not need third party libraries. but I did not get how can I import a third party library. ps: I have docker installed in my machine
答案1
得分: 6
答案仍然是一样的:你不能在“官方”的Go Playground(https://play.golang.org/)上做那样的事情。
如果你或其他人运行的是自定义的、修改过的Go Playground版本:那么答案是你可以在那里做任何被允许的事情,这可能包括在编译和执行之前使用自定义引擎可能的go get
外部库。
另请参阅相关问题:https://stackoverflow.com/questions/36409302/which-packages-may-be-imported-in-the-go-playground
英文:
The answer is still the same: you can't do that on the "official" Go Playground (at https://play.golang.org/).
If you or someone else runs a custom, modified version of the Go Playground: then the answer is you can do there whatever is allowed, which may include the usage of external libraries which the custom engine may go get
prior to compilation and execution.
Also see related question: https://stackoverflow.com/questions/36409302/which-packages-may-be-imported-in-the-go-playground
答案2
得分: 3
你可能可以自2019年5月14日起这样做。
参见这条推文(来自Brad Fitzpatrick)!
#golang playground现在支持第三方导入,通过https://proxy.golang.org/引入它们
示例:https://play.golang.org/p/eqEo7mqdS9l 🎉
接下来是多文件支持和其他一些功能。
在golang/go
问题31944上报告错误,或在推特上报告。
但这意味着你已经以某种方式发布了你的软件包可交付物,它被Go代理引用。
英文:
You might be able to do it since May 14th, 2019
See this tweet (from Brad Fitzpatrick)!
> The #golang playground now supports third-party imports, pulling them in via https://proxy.golang.org/
>
> Example: https://play.golang.org/p/eqEo7mqdS9l 🎉
>
> Multi-file support & few other things up next.
> Report bugs at golang/go
issue 31944, or here on the tweeters.
But that means you have published your package deliverable in such a way it is reference by the Go proxy.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论