Fixed some golint warnings

This commit is contained in:
2016-03-29 03:06:56 +03:00
parent 850344cdd9
commit 945e044bbf
2 changed files with 17 additions and 13 deletions

12
main.go
View File

@@ -17,10 +17,16 @@ import (
const ( const (
// time between processing xinput output // time between processing xinput output
SLEEP_TIME = 3 * time.Second SLEEP_TIME = 3 * time.Second
// Buffer that we read from xinput
KEYBOARD_BUFER_SIZE = 10000 KEYBOARD_BUFER_SIZE = 10000
DATABASE_NAME = "file:gokeystat.db?cache=shared&mode=rwc"
CAPTURE_TIME = 5 // time in seconds between capturing keyboard to db // Database that stores keylog and other settings
DATABASE_NAME = "file:gokeystat.db?cache=shared&mode=rwc"
// time in seconds between capturing keyboard to db
CAPTURE_TIME = 5
) )
// StatForTime stotres pressed keys and beginning time // StatForTime stotres pressed keys and beginning time

View File

@@ -8,7 +8,6 @@ import (
"io" "io"
"log" "log"
"os" "os"
"sort"
"strconv" "strconv"
) )
@@ -16,17 +15,15 @@ import (
// if fullExport saves log for each key else only sum for keys // if fullExport saves log for each key else only sum for keys
func SaveToCsvWriter(data []StatForTime, keyMap map[uint8]string, writerOut io.Writer, fullExport bool) { func SaveToCsvWriter(data []StatForTime, keyMap map[uint8]string, writerOut io.Writer, fullExport bool) {
numKeysInt := make([]int, 0) numKeysInt := GetKeyNumsFromKeyMap(keyMap)
for key := range keyMap {
numKeysInt = append(numKeysInt, int(key)) var numKeys []uint8
}
sort.Ints(numKeysInt)
numKeys := make([]uint8, 0)
for _, key := range numKeysInt { for _, key := range numKeysInt {
numKeys = append(numKeys, uint8(key)) numKeys = append(numKeys, uint8(key))
} }
titleLine := make([]string, 0) var titleLine []string
titleLine = append(titleLine, "Time") titleLine = append(titleLine, "Time")
if fullExport { if fullExport {
for _, key := range numKeys { for _, key := range numKeys {
@@ -35,10 +32,11 @@ func SaveToCsvWriter(data []StatForTime, keyMap map[uint8]string, writerOut io.W
} }
titleLine = append(titleLine, "Sum") titleLine = append(titleLine, "Sum")
table := make([][]string, 0) var table [][]string
table = append(table, titleLine) table = append(table, titleLine)
for _, rec := range data { for _, rec := range data {
line := make([]string, 0) var line []string
line = append(line, strconv.Itoa(int(rec.time))) line = append(line, strconv.Itoa(int(rec.time)))
var sum int var sum int
for _, key := range numKeys { for _, key := range numKeys {