-
Notifications
You must be signed in to change notification settings - Fork 0
/
autotest.go
57 lines (42 loc) · 948 Bytes
/
autotest.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"database/sql"
"fmt"
"log"
)
type AutotestStruct struct {
}
func (o *AutotestStruct) Run() error {
var err error
var SQL string
SQLdb := Cache.GetSQLConnection()
SQL = `select "prefix", "name" from providerlist`
Row, err := SQLdb.Query(SQL)
if err != nil {
log.Panic(err)
}
var OUI = ObservationUIStruct{ShowIdentifiers: true}
defer Row.Close()
for Row.Next() {
var Prefix, Name string
err = Row.Scan(&Prefix, &Name)
if err != nil {
log.Panic(err)
}
if len(Prefix) == 0 {
Prefix = "-"
}
SQL = `SELECT Identifier FROM Stationlist WHERE Identifier LIKE "` + Prefix + `%" ORDER BY RANDOM() LIMIT 1`
var Identifier string
err = SQLdb.QueryRow(SQL).Scan(&Identifier)
if err == sql.ErrNoRows {
fmt.Println("Prefix", Prefix, "empty")
continue
} else if err != nil {
log.Panic(err)
}
OUI.Station = OUI.Station + Identifier + " "
}
err = OUI.Get()
return err
}