使用WebAssembly在网页上运行CLI GO应用程序

发布于 2025-02-05 11:49:32 字数 983 浏览 1 评论 0原文

我一直在使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文