func (Ips IpMap) Dump(w io.Writer, when time.Time) error {
	wb := bufio.NewWriter(w)
	whenString := when.Format(CsvTimeFormat)
	_, err := fmt.Fprintf(wb, "Time,IP,SourceBytes,SourcePackets,DestBytes,DestPackets\n")
	if err != nil {
		return err
	}
	for key, stat := range Ips {
		ip := net.IP(key)
		_, err := fmt.Fprintf(wb, "%s,%s,%d,%d,%d,%d\n", whenString, ip, stat.Source.Bytes, stat.Source.Packets, stat.Dest.Bytes, stat.Dest.Packets)
		if err != nil {
			return err
		}
	}
	return wb.Flush()
}
Dump the IpMap to the output as a CSV
package main
import (
	"bufio"
	"flag"
	"fmt"
	"io"
	"log"
	"log/syslog"
	"net"
	"os"
	"os/signal"
	"path"
	"runtime"
	"runtime/pprof"
	"sync"
	"syscall"
	"time"
)
const (
	CsvTimeFormat = "2006-01-02 15:04:05"
	FileTimeFormat = "2006-01-02-150405"
	AddPacketsQueueSize = 8
)
var (
	IPv4SourceGroup  = flag.Int("ip4-src-group", 0, "NFLog Group to read IPv4 packets and account the source address")
	IPv4DestGroup    = flag.Int("ip4-dst-group", 0, "NFLog Group to read IPv4 packets and account the destination address")
	IPv4PrefixLength = flag.Int("ip4-prefix-length", 32, "Size of the IPv4 prefix to account to, default is /32")
	IPv6SourceGroup  = flag.Int("ip6-src-group", 0, "NFLog Group to read IPv6 packets and account the source address")
	IPv6DestGroup    = flag.Int("ip6-dst-group", 0, "NFLog Group to read IPv6 packets and account the destination address")
	IPv6PrefixLength = flag.Int("ip6-prefix-length", 64, "Size of the IPv6 prefix to account to, default is /64")
	Cpus             = flag.Int("cpus", 0, "Number of CPUs to use - default 0 is all of them")
	UseSyslog        = flag.Bool("syslog", false, "Use Syslog for logging")
	Debug            = flag.Bool("debug", false, "Print every single packet that arrives")
	Verbose          = flag.Bool("verbose", false, "Print more logging stuff")
	Interval         = flag.Duration("interval", time.Minute*5, "Interval to log stats")
	LogDirectory     = flag.String("log-directory", "/var/log/accounting", "Directory to write accounting files to.")
	CpuProfile       = flag.String("cpuprofile", "", "Write cpu profile to file")
	MemProfile       = flag.String("memprofile", "", "write memory profile to this file")
	Priority         = flag.Int("priority", -19, "Set priority level")
	BaseName       = path.Base(os.Args[0])
	Version        = "0.1"
	DefaultMapSize = 1024
)
type HalfIpStats struct {
	Bytes   int64
	Packets int64
}
type IpStats struct {
	Source HalfIpStats
	Dest   HalfIpStats
}
type IpMap map[string]*IpStats