Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
github.chickoi.com/nanobox-io/golang-scribble
A tiny JSON database in Golang
Install using go get github.com/nanobox-io/golang-scribble
.
// a new scribble driver, providing the directory where it will be writing to,
// and a qualified logger if desired
db, err := scribble.New(dir, nil)
if err != nil {
fmt.Println("Error", err)
}
// Write a fish to the database
fish := Fish{}
if err := db.Write("fish", "onefish", fish); err != nil {
fmt.Println("Error", err)
}
// Read a fish from the database (passing fish by reference)
onefish := Fish{}
if err := db.Read("fish", "onefish", &onefish); err != nil {
fmt.Println("Error", err)
}
// Read all fish from the database, unmarshaling the response.
records, err := db.ReadAll("fish")
if err != nil {
fmt.Println("Error", err)
}
fishies := []Fish{}
for _, f := range records {
fishFound := Fish{}
if err := json.Unmarshal([]byte(f), &fishFound); err != nil {
fmt.Println("Error", err)
}
fishies = append(fishies, fishFound)
}
// Delete a fish from the database
if err := db.Delete("fish", "onefish"); err != nil {
fmt.Println("Error", err)
}
// Delete all fish from the database
if err := db.Delete("fish", ""); err != nil {
fmt.Println("Error", err)
}
Contributions to scribble are welcome and encouraged. Scribble is a Nanobox project and contributions should follow the Nanobox Contribution Process & Guidelines.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.