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