talks

git clone git://code.dwrz.net/talks
Log | Files | Refs

main.go (649B)


      1 package main
      2 
      3 import (
      4 	"log"
      5 	"os"
      6 	"time"
      7 )
      8 
      9 type ZipTemp struct {
     10 	City        string
     11 	Latitude    string
     12 	Longitude   string
     13 	State       string
     14 	Temperature float64
     15 	Time        time.Time
     16 	ZipCode     string
     17 }
     18 
     19 func main() {
     20 	file, err := os.Open("./zipcodes-50.csv")
     21 	if err != nil {
     22 		log.Fatal(err)
     23 	}
     24 	defer file.Close()
     25 
     26 	// Set up channels.
     27 	var (
     28 		done   = make(chan struct{})
     29 		ztchan = make(chan *ZipTemp)
     30 		ttchan = make(chan []*ZipTemp)
     31 	)
     32 
     33 	// Start the rank and display goroutines.
     34 	go rank(ztchan, ttchan)
     35 	go display(ttchan, done)
     36 
     37 	// Process the CSV.
     38 	processCSV(file, ztchan)
     39 
     40 	// Wait for the last display output.
     41 	<-done
     42 }