本文介紹了兩個新的 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中文網其他相關文章!