@@ -74,28 +74,32 @@ type CSVRecord struct {
74
74
}
75
75
76
76
func main () {
77
+ if _ , err := os .Stat ("../../SlackMessages" ); os .IsNotExist (err ) {
78
+ log .Fatal ("the ./SlackMessages directory does not exist" )
79
+ }
80
+
77
81
files , err := filepath .Glob ("../../SlackMessages/*.json" )
78
82
if err != nil {
79
83
log .Fatal (err )
80
84
}
81
85
82
86
if len (files ) == 0 {
83
- log .Fatal ("Could not find *.json files in the ./SlackMessages directory" )
87
+ log .Fatal ("could not find *.json files in the ./SlackMessages directory" )
84
88
}
85
89
86
90
messages := make ([]* Message , 0 )
87
91
88
92
for _ , file := range files {
89
93
bytes , err := os .ReadFile (file )
90
94
if err != nil {
91
- fmt .Printf ("Error occured while opening %s: %+v\n " , file , err )
95
+ fmt .Printf ("error occured while opening %s: %+v\n " , file , err )
92
96
continue
93
97
}
94
98
95
99
fileMessages := make ([]* Message , 0 )
96
100
err = json .Unmarshal (bytes , & fileMessages )
97
101
if err != nil {
98
- fmt .Printf ("Error occured while parsing JSON from %s: %+v\n " , file , err )
102
+ fmt .Printf ("error occured while parsing JSON from %s: %+v\n " , file , err )
99
103
continue
100
104
}
101
105
@@ -116,13 +120,13 @@ func main() {
116
120
timeStampSplit := strings .Split (msg .TS , "." )
117
121
seconds , err := strconv .ParseInt (timeStampSplit [0 ], 10 , 64 )
118
122
if err != nil {
119
- fmt .Printf ("Error occured while parsing seconds: %+v\n " , err )
123
+ fmt .Printf ("error occured while parsing seconds: %+v\n " , err )
120
124
continue
121
125
}
122
126
123
127
nanoseconds , err := strconv .ParseInt (timeStampSplit [1 ], 10 , 64 )
124
128
if err != nil {
125
- fmt .Printf ("Error occured while parsing nanoseconds: %+v\n " , err )
129
+ fmt .Printf ("error occured while parsing nanoseconds: %+v\n " , err )
126
130
continue
127
131
}
128
132
0 commit comments