fix code style

This commit is contained in:
Chakib Ben Ziane 2017-11-19 20:46:24 +01:00
parent 3c5339f2eb
commit a51707a7a7
3 changed files with 12 additions and 12 deletions

View File

@ -1,6 +1,6 @@
package main
type BrowserType int
type BrowserType uint8
const (
Chrome BrowserType = iota

15
db.go
View File

@ -12,7 +12,9 @@ import (
// Global cache database
var (
cacheDB *DB // Main in memory db, is synced with disc
cacheDB *DB // Main in memory db, is synced with disc
_sql3conns []*sqlite3.SQLiteConn // Only used for backup hook
backupHookRegistered bool // set to true once the backup hook is registered
)
const (
@ -46,9 +48,6 @@ const (
)`
)
var _sql3conns []*sqlite3.SQLiteConn // Only used for backup hook
var BACKUPHOOK_REGISTERED bool
// DB encapsulates an sql.DB
// all itneractions with memory/buffer and disk databases
// is done through the DB object
@ -101,7 +100,7 @@ func (db *DB) Init() {
err = tx.Commit()
logPanic(err)
if !BACKUPHOOK_REGISTERED {
if !backupHookRegistered {
//debugPrint("backup_hook: registering driver %s", DB_BACKUP_HOOK)
// Register the hook
sql.Register(DB_BACKUP_HOOK,
@ -113,7 +112,7 @@ func (db *DB) Init() {
return nil
},
})
BACKUPHOOK_REGISTERED = true
backupHookRegistered = true
}
debugPrint("<%s> initialized", db.name)
@ -203,7 +202,7 @@ func (src *DB) SyncTo(dst *DB) {
func (src *DB) SyncToDisk(dbpath string) error {
if !BACKUPHOOK_REGISTERED {
if !backupHookRegistered {
errMsg := fmt.Sprintf("%s, %s", src.path, "db backup hook is not initialized")
return errors.New(errMsg)
}
@ -243,7 +242,7 @@ func (src *DB) SyncToDisk(dbpath string) error {
func (dst *DB) SyncFromDisk(dbpath string) error {
if !BACKUPHOOK_REGISTERED {
if !backupHookRegistered {
errMsg := fmt.Sprintf("%s, %s", dst.path, "db backup hook is not initialized")
return errors.New(errMsg)
}

View File

@ -27,7 +27,8 @@ var jsonNodePaths = struct {
Type, Children, Url string
}{"type", "children", "url"}
type parseFunc func([]byte, []byte, jsonparser.ValueType, int) error
type ParseChildFunc func([]byte, jsonparser.ValueType, int, error)
type RecursiveParseFunc func([]byte, []byte, jsonparser.ValueType, int) error
func _s(value interface{}) string {
return string(value.([]byte))
@ -52,8 +53,8 @@ func googleParseBookmarks(bw *bookmarkWatcher) {
f, err := ioutil.ReadFile(bookmarkPath)
logPanic(err)
var parseChildren func([]byte, jsonparser.ValueType, int, error)
var gJsonParseRecursive func([]byte, []byte, jsonparser.ValueType, int) error
var parseChildren ParseChildFunc
var gJsonParseRecursive RecursiveParseFunc
parseChildren = func(childVal []byte, dataType jsonparser.ValueType, offset int, err error) {
if err != nil {