首页 > 后端开发 > Golang > 用于构建 golang 代码的有用终端插件

用于构建 golang 代码的有用终端插件

Barbara Streisand
发布: 2025-01-24 18:05:11
原创
725 人浏览过

Useful terminal plugins to build golang code

本文介绍了两个新的 Sparrow 插件,旨在简化终端内的 Golang 开发:go-buildgo-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-buildgo-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中文网其他相关文章!

来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板