DEV Community

Cover image for Useful Golang packages and tools
z0al
z0al

Posted on • Originally published at zoal.dev on

Useful Golang packages and tools

Cover image from: https://golang.org/doc/gopher/biplane.jpg

I recently built my first Go language program ever 🙌. In this post I would like to share some Go packages I found very useful.

So without further ado let’s get started :)

GoReleaser

Building and distributing binaries for several platforms can be challenging. GoRelaeser helps you to automate delivering your app binaries with ease. It can generate archived release files (i.e. binaries + LICENSE + README files), checksums, Homebrew taps, Docker images, snap packages, release to GitHub (including the generating of customizable changelog 😃 ) and much more.

It works well with Travis and CircleCI, so you can automate almost everything 👌

🔗 http://github.com/goreleaser

Cobra

Cobra is both a library for creating powerful modern CLI applications as well as a program to generate applications and command files. Cobra provides you everything you want to build awesome CLI, including sub-commands, automatic usage message, Pre and post run hooks, and generation of Man Page/Markdown/ResStructuredText docs.

Also, it provides automatic (without any configuration) suggestions when “unknown command” happens, e.g (yes, Hugo is powered by Cobra):

$ hugo srever
Error: unknown command "srever" for "hugo"

Did you mean this?
        server

Run 'hugo --help' for usage.
Enter fullscreen mode Exit fullscreen mode

🔗 https://github.com/spf13/cobra

Survey

Do you love Node.js inquirer package? if yes, then you will probably love Survey too. While it doesn’t support yet all the features provided by inquirer, it has all the basic features and very easy to usage.

Survey package in action

🔗 https://github.com/AlecAivazis/survey

Chalk

Again, if you are familiar with npm packages like chalk, you will feel home here. Chalk is a go package for styling console/terminal output. like this:

🔗 https://godoc.org/github.com/ttacon/chalk

go-gitconfig

Probably is the smallest package of them all, but I find it really useful in git-related projects. It’s helpful when you want to extract some info from the global ~/.gitconfig or the local .git/config files. Here is a portion of the code I used to extract origin URL value to fetch remote issues from GitHub:

import (
    config "github.com/tcnksm/go-gitconfig"
)

remote := "origin"
url, err := config.Local(fmt.Sprintf("remote.%s.url", remote))

if err != nil {
    // .. print error
}
// use "url" value here to fetch from GitHub
Enter fullscreen mode Exit fullscreen mode

🔗 https://github.com/tcnksm/go-gitconfig

Other link(s)

  1. A curated list of awesome Go frameworks, libraries and software
  2. List of useful(standard) go tools by @plutov
  3. My simple Git based To-Dos app written in Go

I hope you find this post useful. Thank you ;)


Originally posted on my blog

Top comments (7)

Collapse
 
der_gopher profile image
Alex Pliutau

Nice article Ahmed. A bit related about tools - pliutau.com/go-tools-are-awesome/

Collapse
 
martyonthefly profile image
Sylvain Marty

Very useful post ! Thank you for sharing <3

Collapse
 
z0al profile image
z0al

Glad you find it useful, you're welcome :)

Collapse
 
ryuheechul profile image
Heechul Ryu

Very interesting and useful, thanks!

Collapse
 
z0al profile image
z0al

You're welcome :)

Collapse
 
defman profile image
Sergey Kislyakov

My first article that I added to the reading list on dev.to. Thanks for sharing these packages!

Collapse
 
anikhasibul profile image
Hasibul Hasan (Anik)

Thanks for sharing!