Go program to remove all duplicate entries from a slice

Well, I was working on a go program which is able to remove all duplicate email id’s collected in a log file. While doing so I thought to publish a blog so that I can save some one’s time who is looking out a similar solution on the web.
The program that I coded here is responsible for removing all duplicate email id’s from a log file. Instead of writing much let's move ahead.

Problem Statement:

Consider an application is writing a log file. This log file contains the data like id, firstName, lastName, and email id. Ideally, all duplicate email fields should not be allowed, for that purpose, we should have a program which can find all unique ids for further processing and display all duplicate email id’s.

Consider below log file which is an input to our program. Name of the file is emailsorterdata.log


As you can see 20 emails have been registered containing duplicate email id’s.

Go Code


You can find this program here @ Github
Go program: https://github.com/dmilind/golang/blob/master/codingFun/emailSorter.go
Log File: https://github.com/dmilind/golang/blob/master/codingFun/emailsorterdata.log



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store