Skip to content

Commit

Permalink
Optimized code
Browse files Browse the repository at this point in the history
  • Loading branch information
ErrorNoInternet committed Jul 17, 2021
1 parent 213da3e commit 60d28f2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ func reverseIntArray(array []int) []int {
}

var okDatabase *diskv.Diskv
var currentVersion string = "1.4.7"
var currentVersion string = "1.4.8"

func main() {
databasePath := "OkDatabase"
databasePath := ".OkDatabase"
userObject, errorObject := user.Current()
if errorObject != nil {
panic(errorObject)
Expand All @@ -65,7 +65,7 @@ func main() {
_, errorObject := os.Stat(databasePath)
if errorObject != nil {
if !strings.Contains(errorObject.Error(), "no such") {
databasePath = "OkDatabase"
databasePath = ".OkDatabase"
}
}
} else if runtime.GOOS == "windows" {
Expand All @@ -84,7 +84,7 @@ func main() {
okDatabase := diskv.New(diskv.Options{
BasePath: databasePath,
Transform: flatTransform,
CacheSizeMax: 1024 * 128,
CacheSizeMax: 1024 * 32,
})

arguments := os.Args[1:]
Expand Down Expand Up @@ -423,6 +423,8 @@ func main() {
if errorObject == nil {
currentCountInt64, _ := strconv.ParseInt(string(currentCountBytes), 10, 0)
currentCount = int(currentCountInt64)
} else {
fmt.Println("Error")
}
okDatabase.Write("DAY."+strconv.Itoa(currentDay), []byte(strconv.Itoa(currentCount+1)))

Expand All @@ -431,6 +433,8 @@ func main() {
if errorObject == nil {
currentCountInt64, _ := strconv.ParseInt(string(currentCountBytes), 10, 0)
currentCount = int(currentCountInt64)
} else {
fmt.Println("Error")
}
okDatabase.Write("counter", []byte(strconv.Itoa(currentCount+1)))

Expand Down

0 comments on commit 60d28f2

Please sign in to comment.