Skip to content
/ tofu Public

Simple golang collection helper for get value in an `interface{}` by `value.path`.

License

Notifications You must be signed in to change notification settings

owles/tofu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tofu

Simple golang collection helper for get value in an interface{} by value.path.

Install and usage

go get github.com/owles/tofu

For get value use . separated pah.

myMap := map[string]interface{}{
    "foo": map[string]interface{}{
        "bar": []string{"apple", "orange", "potato"},	
    }
}

val := tofu.Get(myMap, "foo.bar.0", "default")
fmt.Println(val) // apple

val = tofu.Get(myMap, "foo.bar.baz")
fmt.Println(val) // nil

About

Simple golang collection helper for get value in an `interface{}` by `value.path`.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages