DEV Community

Alexey Melezhik
Alexey Melezhik

Posted on

4

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode
#!raku

my $path = [
  "cmd/app/main.go",
  "cmd/cli/cli.go"
];


task-run "build", "go-build", %(
  :$path,
);
Enter fullscreen mode Exit fullscreen mode

Go-format scenario:

#!bash

tom --cat go-format
Enter fullscreen mode Exit fullscreen mode
#!bash

task-run "go format", "go-format";
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode
#!raku

my $path = [
  "cmd/app/app.go",
  "cmd/app2/app2.go",
];

# the rest of the code stays the same 
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode
#!bash
tom go-format
11:57:18 :: cmd/main.go
Enter fullscreen mode Exit fullscreen mode

That is it.

Follow plugins documentation to get familiar with plugins parameters.

Thanks for reading

đź‘‹ While you are here

Reinvent your career. Join DEV.

It takes one minute and is worth it for your career.

Get started

Top comments (0)

đź‘‹ Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay