Better Programming

Advice for programmers.

Follow publication

Member-only story

Build Your First Golang CLI Tool for JSON Validation

Ujjwal Sharma
Better Programming
Published in
4 min readSep 7, 2021

--

Photo by Sai Kiran Anagani on Unsplash

I have been working with Golang for the past 3 months and I finally decided to make something remarkable that will help me upgrade my skills. What is a better way to do this than designing an application but for the command line! Let's get started.

What We Will Build?

We will build a command-line tool that will help us to validate the JSON text inside a text file and tell us if the file is correctly formatted or not.

If the file is correctly formatted, the user can provide us with an option to generate a properly formatted JSON file using the command line arguments.

We can also set verbose level for our application which means we might be able to tell the user if the file is not correctly formatted, what is the error and on which line it’s detected. The error handling is pretty basic for this example which includes a bracket and quote check. However, the main complexity is in providing the user with the verbose ability and finding out the location of the error.

Prerequisites

You should know basic Golang Syntax to understand the code. If you have an understanding of slices, functions, pointers, and control

--

--

Ujjwal Sharma
Ujjwal Sharma

Written by Ujjwal Sharma

SDE 2 @ Intuit | Ex. Google | Dreamer | Developer

Write a response