https://github.com/scientific-dev/gocollection
Simple key:value utility data structure for golang!
https://github.com/scientific-dev/gocollection
cache collection golang
Last synced: about 1 year ago
JSON representation
Simple key:value utility data structure for golang!
- Host: GitHub
- URL: https://github.com/scientific-dev/gocollection
- Owner: scientific-dev
- License: mit
- Created: 2021-02-01T11:17:24.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-08-16T10:16:00.000Z (almost 5 years ago)
- Last Synced: 2024-11-25T17:48:14.702Z (over 1 year ago)
- Topics: cache, collection, golang
- Language: Go
- Homepage: https://pkg.go.dev/github.com/scientific-dev/gocollection
- Size: 14.6 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GoCollection
Simple key:value based utility data structure for golang!
## Quick Example
First install the package!
```sh
go get github.com/scientific-dev/gocollection
```
In your golang file!
```go
package main
import "fmt"
import collection "github.com/scientific-dev/gocollection"
func main() {
col := collection.Collection()
col.Set("foo", "bar")
fmt.Println(col.Get("foo")) // Will return "bar"
}
```
It is basically a better version of `map` in golang! GoCollection uses `map[string]interface{}` as a map typing!
### Storing structs
So incase if you are not aware how to store structs using this, here is quick tuto
```go
package main
import "fmt"
import collection "github.com/scientific-dev/gocollection"
type SimpleStruct struct{
field string
}
func main() {
col := collection.Collection()
col.Set("foo", SimpleStruct{ field: "string" })
fmt.Println(col.Get("foo").(SimpleStruct).field) // You can use the basic type conversion of golang for this!
}
```
## Support
Any kind of doubts on this package, you can make an issue in the github repo or join our discord server and ask us doubts!
**Discord Server:** [https://discord.gg/FrduEZd](https://discord.gg/FrduEZd)
**GitHub Repo:** [https://github.com/scientific-dev/gocollection/](https://github.com/scientific-dev/gocollection)
**Docs:** [https://github.com/scientific-dev/gocollection/wiki/Go-Collection](https://github.com/scientific-dev/gocollection/wiki/Go-Collection)
**Golang:** [https://pkg.go.dev/github.com/scientific-dev/gocollection](https://pkg.go.dev/github.com/scientific-dev/gocollection)