英文:
Go WebAssembly with gRPC Web
问题
我想使用主要使用Go编写的WebAssembly制作一个网站,并且我想使用gRPC协议。由于Web的限制,我必须使用gRPC的“Web版本协议”,它可以编译为JavaScript库。请问我如何在Go中编译这个“Web版本”呢?我找到了这个有用的编译工具:https://github.com/namely/docker-protoc
英文:
I want to make a website using webassembly written mainly in go, and I would like to use grpc protocol, due the web restrictions, I have to use the "web version protocol" of grpc, and it can be compiled to js library, and how can I compile the "web version" in go?
I found this useful to compile: https://github.com/namely/docker-protoc
答案1
得分: 3
有趣的问题,但我认为你目前还不能这样做。
存在两个问题:
- 浏览器中的WASM目前无法访问Web API。
- 唯一的gRPC-Web SDK是JavaScript的(而且,由于浏览器中的WASM无法访问Web API,即使你用Golang编写了一个SDK,当你将应用程序编译为WASM时,在浏览器中也无法正常工作)。
英文:
Interesting question but I think (!?) you can't yet do this.
There are >2 issues:
- WASM in the browser is currently unable (!?) to access Web APIs.
- The only gRPC-Web SDK is JavaScript (and, since WASM in the browser can't access Web APIs, even if you wrote one in Golang, when you compiled apps using it to WASM, the wouldn't work in the browser)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论