Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement method do get all existing key-value pairs in a store #9

Open
philippgille opened this issue Oct 22, 2018 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@philippgille
Copy link
Owner

As mentioned in the README already, something like List(interface{}) error or GetAll(interface{}) error should be implemented.

Example of how a user could pass a slice which the List method then populates with values:

package main

import (
	"encoding/json"
	"fmt"
)

type foo struct {
	Bar string
}

// myFunc is meant to populate the passed slice of pointers
func myFunc(vals interface{}) {
	j := []byte(`[{"Bar":"baz1"},{"Bar":"baz2"}]`)

	err := json.Unmarshal(j, vals)
	if err != nil {
		panic(err)
	}
}

func main() {
	fmt.Println("Hello world!")

	vals := make([]foo, 0)
	myFunc(&vals)
	fmt.Println("vals:")
	for _, v := range vals {
		fmt.Printf("%+v\n", v)
	}
}

Output:

Hello world!
vals:
{Bar:baz1}
{Bar:baz2}
@philippgille philippgille added the enhancement New feature or request label Oct 22, 2018
glimchb added a commit to glimchb/gokv that referenced this issue Dec 28, 2023
glimchb added a commit to glimchb/gokv that referenced this issue Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant