AI Features

Solution 2: Reflection and Interfaces

Let’s solve the challenges set in the previous lesson.

Problem 1: Solution

Here is the integration of the functionality of sortCSV.go in phonebook.go.

Mihalis,Tsoukalos,210,9416471,1609310706
Dimitris,Tsoukalos,210,9416871,1609310731
Mihalis,Tsoukalos,210,9416571,1609310717
Dimitris,Tsoukalos,210,9416971,1609310734
Jane,Doe,0800,123456,1609310777
phoneBook.go

Code explanation

The code reads data from a CSV file, either in Format 1 or Format 2. Format 1 has four fields (name, surname, telephone, last access date), and Format 2 has five fields (name, surname, area code, telephone, last access date). The program determines the format of the file by ...