使用WebAssembly在网页上运行CLI GO应用程序
我一直在使用Brilliant Go程序 go-nexrad 。我可以使用一些设置在计算机(M1 MacBook Pro)上运行此操作:
git clone https://github.com/bwiggs/go-nexrad.git
cd go-nexrad && cd cmd && cd nexrad-render
# these two commands are just to download radar files
aws s3 cp --no-sign-request s3://noaa-nexrad-level2/2017/08/25/KCRP/KCRP20170825_235733_V06 .
aws s3 cp --no-sign-request s3://noaa-nexrad-level2/2022/04/18/KLWX/KLWX20220418_153931_V06 .
go get -u golang.org/x/sys
然后我可以运行一个命令,例如go go运行。 -f kcrp20170825_235733_v06 -s 2048 -p ref
在同一目录中生成radar.png
文件。
我知道WebAssembly能够编译GO程序以在网页上运行,但是我不确定如何使用此框架与CLI应用程序进行交互。我在线找到了几个指南,但是它们用于简单应用程序,该程序只需将用户输入即可将结果记录到控制台。
该程序必须稍微复杂一些,因为它必须编写一个全新的png
文件。
是否有人知道我可以通过与相关CLI命令进行交互的方式,例如指定雷达文件并通过命令标志设置产品并在网页上运行?
任何建议将不胜感激。
I have been working with the brilliant Go program go-nexrad. I am able to run this on my computer (M1 MacBook Pro) with some setup:
git clone https://github.com/bwiggs/go-nexrad.git
cd go-nexrad && cd cmd && cd nexrad-render
# these two commands are just to download radar files
aws s3 cp --no-sign-request s3://noaa-nexrad-level2/2017/08/25/KCRP/KCRP20170825_235733_V06 .
aws s3 cp --no-sign-request s3://noaa-nexrad-level2/2022/04/18/KLWX/KLWX20220418_153931_V06 .
go get -u golang.org/x/sys
I can then run a command such as go run . -f KCRP20170825_235733_V06 -s 2048 -p ref
to generate a radar.png
file in the same directory.
I am aware of WebAssembly being able to compile Go programs to run on a webpage, but I am unsure how to interact with a CLI application such as this one using this framework. I have found several guides online, but they are for simple applications where the program just takes user input and then logs the result to the console.
This program is slightly more complex, as it has to write an entirely new png
file.
Does anybody know of a way that I can work with this project in such a way that I can interact with the relevant CLI commands, e.g. specifying a radar file and setting the product via command flags, and have it run on a webpage?
Any advice would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论