本文介绍了两个新的 Sparrow 插件,旨在简化终端内的 Golang 开发:go-build
和 go-format
。这些工具简化了构建和格式化 Golang 代码的基本任务。
安装
这些插件利用 Tomtit 任务运行程序及其配置文件系统。 请按照以下步骤安装:
<code class="language-bash">cd /to/your/source/code tom --init # Initialize Tomtit (if not already done) tom --profile go # Install the Golang profile</code>
go
配置文件提供对 go-build
和 go-format
场景的访问,它们是插件的 Raku 包装器。 这些场景很容易定制。
构建场景:
查看go-build
场景:
<code class="language-bash">tom --cat go-build</code>
这将显示 Raku 代码,它本质上定义了要构建的文件。 例如:
<code class="language-raku">my $path = [ "cmd/app/main.go", "cmd/cli/cli.go" ]; task-run "build", "go-build", %( :$path, );</code>
Go 格式场景:
查看go-format
场景:
<code class="language-bash">tom --cat go-format</code>
这个场景的代码比较简单:
<code class="language-bash">task-run "go format", "go-format";</code>
定制
go-build
场景的 $path
数组可以轻松修改以匹配您的项目结构。 使用您喜欢的编辑器:
<code class="language-bash">export EDITOR=nano # Or your preferred editor tom --edit go-build</code>
然后,调整 $path
数组以包含正确的文件路径。
运行插件
使用 Tomtit CLI 执行插件:
<code class="language-bash">tom go-build # Builds the specified Golang files</code>
<code class="language-bash">tom go-format # Formats the Golang code</code>
有关详细参数选项,请参阅插件文档。 享受简化的 Golang 开发!
以上是用于构建 golang 代码的有用终端插件的详细内容。更多信息请关注PHP中文网其他相关文章!