Useful terminal plugins to build golang code
Recently, I've released 2 new Sparrow plugins to help build Golang code:
Simple golang code builder
Golang code formatter
They are simple yet useful, providing two essentials tools to build Golang code in terminal:
- Build code
- Format code
The rest of the post shows how to use the plugins
Installation
To install plugins we need to use Tomtit task runner with profiles - preset of Raku scenarios that grouped by topics:
#!bash
cd /to/you/source/code
tom --init # initialize Tomtit for the first time
tom --profile go # install go profile scenarios
Now once we've installed go
profile, we have an access to go-build
and go-format
scenarios which are just a Raku wrappers to run mentioned plugins. Code is simple enough and editable to adjust your project specific needs
Go-build scenario:
#!bash
tom --cat go-build
#!raku
my $path = [
"cmd/app/main.go",
"cmd/cli/cli.go"
];
task-run "build", "go-build", %(
:$path,
);
Go-format scenario:
#!bash
tom --cat go-format
#!bash
task-run "go format", "go-format";
Customization
In case of go-build
scenario - adjust path
array with files to build for your project specific:
#!bash
export EDITOR=nano
tom --edit go-build
#!raku
my $path = [
"cmd/app/app.go",
"cmd/app2/app2.go",
];
# the rest of the code stays the same
Run
To run plugins - use tom
cli runner:
#!bash
tom go-build
11:56:26 :: go build cmd/main.go
11:56:27 :: cmd/main.go
#!bash
tom go-format
11:57:18 :: cmd/main.go
That is it.
Follow plugins documentation to get familiar with plugins parameters.
Thanks for reading
Source: View source