Skip to content

Commit

Permalink
This fixes key not found in db error (#60) (#61)
Browse files Browse the repository at this point in the history
* ignore vsc conf

* migrate to a single source of truth for constants

doing this avoides invalid import cycles

* comment out logging for debugging

* delete last edited time from db

* fix key not found in db error (#60)

* fix ci issues
  • Loading branch information
theredditbandit authored Jul 2, 2024
1 parent ee870d4 commit a3cfe1e
Show file tree
Hide file tree
Showing 17 changed files with 134 additions and 99 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ go.work
pman
coverage.out
.idea/*

.vscode/*
9 changes: 5 additions & 4 deletions cmd/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/spf13/cobra"

c "github.com/theredditbandit/pman/constants"
"github.com/theredditbandit/pman/pkg/db"
)

Expand All @@ -28,25 +29,25 @@ avlpn or something smaller and use that to query pman`,
}
pname := args[0]
alias := args[1]
_, err := db.GetRecord(db.DBName, pname, StatusBucket)
_, err := db.GetRecord(db.DBName, pname, c.StatusBucket)
if err != nil {
fmt.Printf("%s project does not exist in db", pname)
return err
}
fmt.Printf("Aliasing %s to %s \n", pname, alias)
data := map[string]string{alias: pname}
revData := map[string]string{pname: alias}
err = db.WriteToDB(db.DBName, data, ProjectAliasBucket)
err = db.WriteToDB(db.DBName, data, c.ProjectAliasBucket)
if err != nil {
return err
}
err = db.WriteToDB(db.DBName, revData, ProjectAliasBucket)
err = db.WriteToDB(db.DBName, revData, c.ProjectAliasBucket)
if err != nil {
return err
}
lastEdit := make(map[string]string)
lastEdit["lastWrite"] = fmt.Sprint(time.Now().Format("02 Jan 06 15:04"))
err = db.WriteToDB(db.DBName, lastEdit, ConfigBucket)
err = db.WriteToDB(db.DBName, lastEdit, c.ConfigBucket)
if err != nil {
log.Print(err)
return err
Expand Down
19 changes: 12 additions & 7 deletions cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/spf13/cobra"

c "github.com/theredditbandit/pman/constants"
"github.com/theredditbandit/pman/pkg/db"
)

Expand All @@ -25,27 +26,31 @@ var delCmd = &cobra.Command{
return ErrBadUsageDelCmd
}
projName := args[0]
_, err := db.GetRecord(db.DBName, projName, StatusBucket)
_, err := db.GetRecord(db.DBName, projName, c.StatusBucket)
if err != nil {
fmt.Printf("%s is not a valid project to be deleted\n", projName)
fmt.Println("Note : projects cannot be deleted using their alias")
return err
}
err = db.DeleteFromDb(db.DBName, projName, ProjectPathBucket)
err = db.DeleteFromDb(db.DBName, projName, c.ProjectPaths)
if err != nil {
return err
}
err = db.DeleteFromDb(db.DBName, projName, StatusBucket)
err = db.DeleteFromDb(db.DBName, projName, c.StatusBucket)
if err != nil {
return err
}
alias, err := db.GetRecord(db.DBName, projName, ProjectAliasBucket)
err = db.DeleteFromDb(db.DBName, projName, c.LastUpdatedBucket)
if err != nil {
return err
}
alias, err := db.GetRecord(db.DBName, projName, c.ProjectAliasBucket)
if err == nil {
err = db.DeleteFromDb(db.DBName, alias, ProjectAliasBucket)
err = db.DeleteFromDb(db.DBName, alias, c.ProjectAliasBucket)
if err != nil {
return err
}
err = db.DeleteFromDb(db.DBName, projName, ProjectAliasBucket)
err = db.DeleteFromDb(db.DBName, projName, c.ProjectAliasBucket)
if err != nil {
return err
}
Expand All @@ -56,7 +61,7 @@ var delCmd = &cobra.Command{
}
lastEdit := make(map[string]string)
lastEdit["lastWrite"] = fmt.Sprint(time.Now().Format("02 Jan 06 15:04"))
err = db.WriteToDB(db.DBName, lastEdit, ConfigBucket)
err = db.WriteToDB(db.DBName, lastEdit, c.ConfigBucket)
if err != nil {
log.Print(err)
return err
Expand Down
3 changes: 2 additions & 1 deletion cmd/i.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/spf13/cobra"

c "github.com/theredditbandit/pman/constants"
"github.com/theredditbandit/pman/pkg/db"
"github.com/theredditbandit/pman/pkg/ui"
"github.com/theredditbandit/pman/pkg/utils"
Expand All @@ -19,7 +20,7 @@ var iCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, _ []string) error {
filterFlag, _ := cmd.Flags().GetString("f")
refreshLastEditTime, _ := cmd.Flags().GetBool("r")
data, err := db.GetAllRecords(db.DBName, StatusBucket)
data, err := db.GetAllRecords(db.DBName, c.StatusBucket)
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/spf13/cobra"

c "github.com/theredditbandit/pman/constants"
"github.com/theredditbandit/pman/pkg/db"
"github.com/theredditbandit/pman/pkg/ui"
"github.com/theredditbandit/pman/pkg/utils"
Expand All @@ -21,7 +22,7 @@ var lsCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, _ []string) error {
filterFlag, _ := cmd.Flags().GetString("f")
refreshLastEditTime, _ := cmd.Flags().GetBool("r")
data, err := db.GetAllRecords(db.DBName, StatusBucket)
data, err := db.GetAllRecords(db.DBName, c.StatusBucket)
if err != nil {
return err
}
Expand Down
10 changes: 2 additions & 8 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@ import (
"errors"

"github.com/spf13/cobra"
)

const (
StatusBucket = "projects"
ProjectPathBucket = "projectPaths"
ProjectAliasBucket = "projectAliases"
ConfigBucket = "config"
version = "1.1.0"
c "github.com/theredditbandit/pman/constants"
)

var (
Expand All @@ -21,7 +15,7 @@ var (
var rootCmd = &cobra.Command{
Use: "pman",
Short: "A cli project manager",
Version: version,
Version: c.Version,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
Expand Down
7 changes: 4 additions & 3 deletions cmd/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/spf13/cobra"

c "github.com/theredditbandit/pman/constants"
"github.com/theredditbandit/pman/pkg/db"
)

Expand Down Expand Up @@ -38,21 +39,21 @@ var setCmd = &cobra.Command{
var pname string
alias := args[0]
status := args[1]
project, err := db.GetRecord(db.DBName, alias, ProjectAliasBucket)
project, err := db.GetRecord(db.DBName, alias, c.ProjectAliasBucket)
if err == nil {
pname = project
} else {
pname = alias
}
err = db.UpdateRec(db.DBName, pname, status, StatusBucket)
err = db.UpdateRec(db.DBName, pname, status, c.StatusBucket)
if err != nil {
fmt.Println("Error updating record : ", err)
return err
}

lastEdit := make(map[string]string)
lastEdit["lastWrite"] = fmt.Sprint(time.Now().Format("02 Jan 06 15:04"))
err = db.WriteToDB(db.DBName, lastEdit, ConfigBucket)
err = db.WriteToDB(db.DBName, lastEdit, c.ConfigBucket)
if err != nil {
log.Print(err)
return err
Expand Down
5 changes: 3 additions & 2 deletions cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/spf13/cobra"

c "github.com/theredditbandit/pman/constants"
"github.com/theredditbandit/pman/pkg/db"
"github.com/theredditbandit/pman/pkg/utils"
)
Expand All @@ -26,12 +27,12 @@ var statusCmd = &cobra.Command{
return ErrBadUsageStatusCmd
}
projName := args[0]
actualName, err := db.GetRecord(db.DBName, projName, ProjectAliasBucket)
actualName, err := db.GetRecord(db.DBName, projName, c.ProjectAliasBucket)
if err == nil { // check if user has supplied an alias instead of actual project name
alias = projName
projName = actualName
}
status, err := db.GetRecord(db.DBName, projName, StatusBucket)
status, err := db.GetRecord(db.DBName, projName, c.StatusBucket)
if err != nil {
fmt.Printf("%s is not a valid project name : Err -> %s", projName, err)
return err
Expand Down
11 changes: 11 additions & 0 deletions constants/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// constants : single source of truth for constants used all over the project
package constants

const (
StatusBucket = "projects"
ProjectPaths = "projectPaths"
ProjectAliasBucket = "projectAliases"
ConfigBucket = "config"
Version = "1.1.0"
LastUpdatedBucket = "lastUpdated"
)
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ go 1.22.2

require (
github.com/charmbracelet/bubbles v0.18.0
github.com/charmbracelet/bubbletea v0.26.4
github.com/charmbracelet/bubbletea v0.26.6
github.com/charmbracelet/glamour v0.7.0
github.com/charmbracelet/lipgloss v0.11.0
github.com/spf13/cobra v1.8.0
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.9.0
go.etcd.io/bbolt v1.3.10
golang.org/x/text v0.16.0
)

require (
github.com/alecthomas/chroma/v2 v2.13.0 // indirect
github.com/alecthomas/chroma/v2 v2.14.0 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/charmbracelet/x/ansi v0.1.2 // indirect
github.com/charmbracelet/x/input v0.1.0 // indirect
github.com/charmbracelet/x/input v0.1.2 // indirect
github.com/charmbracelet/x/term v0.1.1 // indirect
github.com/charmbracelet/x/windows v0.1.0 // indirect
github.com/charmbracelet/x/windows v0.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dlclark/regexp2 v1.11.0 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
Expand All @@ -40,10 +40,10 @@ require (
github.com/rivo/uniseg v0.4.7 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/yuin/goldmark v1.7.1 // indirect
github.com/yuin/goldmark-emoji v1.0.2 // indirect
golang.org/x/net v0.24.0 // indirect
github.com/yuin/goldmark v1.7.4 // indirect
github.com/yuin/goldmark-emoji v1.0.3 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/sys v0.21.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
42 changes: 21 additions & 21 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/alecthomas/assert/v2 v2.6.0 h1:o3WJwILtexrEUk3cUVal3oiQY2tfgr/FHWiz/v2n4FU=
github.com/alecthomas/assert/v2 v2.6.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
github.com/alecthomas/chroma/v2 v2.13.0 h1:VP72+99Fb2zEcYM0MeaWJmV+xQvz5v5cxRHd+ooU1lI=
github.com/alecthomas/chroma/v2 v2.13.0/go.mod h1:BUGjjsD+ndS6eX37YgTchSEG+Jg9Jv1GiZs9sqPqztk=
github.com/alecthomas/assert/v2 v2.7.0 h1:QtqSACNS3tF7oasA8CU6A6sXZSBDqnm7RfpLl9bZqbE=
github.com/alecthomas/assert/v2 v2.7.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E=
github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I=
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
Expand All @@ -10,21 +10,21 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
github.com/charmbracelet/bubbles v0.18.0 h1:PYv1A036luoBGroX6VWjQIE9Syf2Wby2oOl/39KLfy0=
github.com/charmbracelet/bubbles v0.18.0/go.mod h1:08qhZhtIwzgrtBjAcJnij1t1H0ZRjwHyGsy6AL11PSw=
github.com/charmbracelet/bubbletea v0.26.4 h1:2gDkkzLZaTjMl/dQBpNVtnvcCxsh/FCkimep7FC9c40=
github.com/charmbracelet/bubbletea v0.26.4/go.mod h1:P+r+RRA5qtI1DOHNFn0otoNwB4rn+zNAzSj/EXz6xU0=
github.com/charmbracelet/bubbletea v0.26.6 h1:zTCWSuST+3yZYZnVSvbXwKOPRSNZceVeqpzOLN2zq1s=
github.com/charmbracelet/bubbletea v0.26.6/go.mod h1:dz8CWPlfCCGLFbBlTY4N7bjLiyOGDJEnd2Muu7pOWhk=
github.com/charmbracelet/glamour v0.7.0 h1:2BtKGZ4iVJCDfMF229EzbeR1QRKLWztO9dMtjmqZSng=
github.com/charmbracelet/glamour v0.7.0/go.mod h1:jUMh5MeihljJPQbJ/wf4ldw2+yBP59+ctV36jASy7ps=
github.com/charmbracelet/lipgloss v0.11.0 h1:UoAcbQ6Qml8hDwSWs0Y1cB5TEQuZkDPH/ZqwWWYTG4g=
github.com/charmbracelet/lipgloss v0.11.0/go.mod h1:1UdRTH9gYgpcdNN5oBtjbu/IzNKtzVtb7sqN1t9LNn8=
github.com/charmbracelet/x/ansi v0.1.2 h1:6+LR39uG8DE6zAmbu023YlqjJHkYXDF1z36ZwzO4xZY=
github.com/charmbracelet/x/ansi v0.1.2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw=
github.com/charmbracelet/x/input v0.1.0 h1:TEsGSfZYQyOtp+STIjyBq6tpRaorH0qpwZUj8DavAhQ=
github.com/charmbracelet/x/input v0.1.0/go.mod h1:ZZwaBxPF7IG8gWWzPUVqHEtWhc1+HXJPNuerJGRGZ28=
github.com/charmbracelet/x/input v0.1.2 h1:QJAZr33eOhDowkkEQ24rsJy4Llxlm+fRDf/cQrmqJa0=
github.com/charmbracelet/x/input v0.1.2/go.mod h1:LGBim0maUY4Pitjn/4fHnuXb4KirU3DODsyuHuXdOyA=
github.com/charmbracelet/x/term v0.1.1 h1:3cosVAiPOig+EV4X9U+3LDgtwwAoEzJjNdwbXDjF6yI=
github.com/charmbracelet/x/term v0.1.1/go.mod h1:wB1fHt5ECsu3mXYusyzcngVWWlu1KKUmmLhfgr/Flxw=
github.com/charmbracelet/x/windows v0.1.0 h1:gTaxdvzDM5oMa/I2ZNF7wN78X/atWemG9Wph7Ika2k4=
github.com/charmbracelet/x/windows v0.1.0/go.mod h1:GLEO/l+lizvFDBPLIOk+49gdX49L9YWMB5t+DZd0jkQ=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/charmbracelet/x/windows v0.1.2 h1:Iumiwq2G+BRmgoayww/qfcvof7W/3uLoelhxojXlRWg=
github.com/charmbracelet/x/windows v0.1.2/go.mod h1:GLEO/l+lizvFDBPLIOk+49gdX49L9YWMB5t+DZd0jkQ=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
Expand Down Expand Up @@ -66,31 +66,31 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
github.com/yuin/goldmark v1.3.7/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.7.1 h1:3bajkSilaCbjdKVsKdZjZCLBNPL9pYzrCakKaf4U49U=
github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
github.com/yuin/goldmark-emoji v1.0.2 h1:c/RgTShNgHTtc6xdz2KKI74jJr6rWi7FPgnP9GAsO5s=
github.com/yuin/goldmark-emoji v1.0.2/go.mod h1:RhP/RWpexdp+KHs7ghKnifRoIs/Bq4nDS7tRbCkOwKY=
github.com/yuin/goldmark v1.7.4 h1:BDXOHExt+A7gwPCJgPIIq7ENvceR7we7rOS9TNoLZeg=
github.com/yuin/goldmark v1.7.4/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
github.com/yuin/goldmark-emoji v1.0.3 h1:aLRkLHOuBR2czCY4R8olwMjID+tENfhyFDMCRhbIQY4=
github.com/yuin/goldmark-emoji v1.0.3/go.mod h1:tTkZEbwu5wkPmgTcitqddVxY9osFZiavD+r4AzQrh1U=
go.etcd.io/bbolt v1.3.10 h1:+BqfJTcCzTItrop8mq/lbzL8wSGtj94UO/3U31shqG0=
go.etcd.io/bbolt v1.3.10/go.mod h1:bK3UQLPJZly7IlNmV7uVHJDxfe5aK9Ll93e/74Y9oEQ=
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E=
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
Expand Down
2 changes: 2 additions & 0 deletions pkg/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@ func GetRecord(dbname, key, bucketName string) (string, error) {
err = db.View(func(tx *bolt.Tx) error {
bucket := tx.Bucket([]byte(bucketName))
if bucket == nil {
// log.Println("bucket not found error", bucketName,"for key")
return ErrBucketNotFound
}
v := bucket.Get([]byte(key))
if v == nil {
// log.Println("key not found error", key)
return ErrKeyNotFound
}
rec = string(v)
Expand Down
Loading

0 comments on commit a3cfe1e

Please sign in to comment.