Add concurrency

This commit is contained in:
dwrz
2026-10-27 12:41:06 +00:00
commit 2334f4eaf0
31 changed files with 43061 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
package main
import (
"log"
"os"
"time"
)
type ZipTemp struct {
City string
Latitude string
Longitude string
State string
Temperature float64
Time time.Time
ZipCode string
}
func main() {
file, err := os.Open("./zipcodes-50.csv")
if err != nil {
log.Fatal(err)
}
defer file.Close()
// Set up channels.
var (
done = make(chan struct{})
ztchan = make(chan *ZipTemp)
ttchan = make(chan []*ZipTemp)
)
// Start the rank and display goroutines.
go rank(ztchan, ttchan)
go display(ttchan, done)
// Process the CSV.
processCSV(file, ztchan)
// Wait for the last display output.
<-done
}