ea6a8028623d — Dang Hoang Tuan (Tsuki) 2 years ago
Add last modified date of files to table
1 files changed, 6 insertions(+), 4 deletions(-)

M helper_functions.go
M helper_functions.go +6 -4
@@ 2,10 2,11 @@ 
 package main
 
 import (
+	"fmt"
 	"io/ioutil"
 	"log"
 	"strings"
-	"fmt"
+	"time"
 
 	"github.com/labstack/echo/v4"
 	"github.com/olekukonko/tablewriter"

          
@@ 19,12 20,13 @@ func displayFolder(c echo.Context, path 
 
 	tableString := &strings.Builder{}
 	table := tablewriter.NewWriter(tableString)
-	table.SetHeader([]string{"TYPE", "NAME", "SIZE"})
+	table.SetHeader([]string{"TYPE", "NAME", "SIZE", "LAST MODIFIED"})
 	for _, file := range files {
+		lastModified := file.ModTime().Format(time.RFC3339)
 		if file.IsDir() {
-			table.Append([]string{"DIR", file.Name(), ByteCountSI(file.Size())})
+			table.Append([]string{"DIR", file.Name(), ByteCountSI(file.Size()), lastModified})
 		} else {
-			table.Append([]string{"FILE", file.Name(), ByteCountSI(file.Size())})
+			table.Append([]string{"FILE", file.Name(), ByteCountSI(file.Size()), lastModified})
 		}
 	}
 	table.Render()