Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uudashr/go-expo
go-expo provides expand expression library.
https://github.com/uudashr/go-expo
Last synced: about 2 months ago
JSON representation
go-expo provides expand expression library.
- Host: GitHub
- URL: https://github.com/uudashr/go-expo
- Owner: uudashr
- License: apache-2.0
- Created: 2017-11-13T13:42:53.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-13T01:58:42.000Z (about 7 years ago)
- Last Synced: 2024-06-20T15:57:24.597Z (7 months ago)
- Language: Go
- Size: 5.86 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![GoDoc](https://godoc.org/github.com/uudashr/go-expo?status.svg)](https://godoc.org/github.com/uudashr/go-expo)
# go-expo
Package expo provides expand expression library.Common usage is on the REST API that provide `expand` key on the URL:
```
https://api.some-blog-service.com/blog?expand=author,publisher.contact
```## Installation
```
go get github.com/uudashr/go-expo
```## Example
```go
opts := expo.ExpandOptions{"author", "publisher.contact"}expand := opts.Expand("author")
fmt.Println("Expand author:", expand)expand = opts.Expand("category")
fmt.Println("Expand category:", expand)expand = opts.Expand("publisher")
fmt.Println("Expand publisher:", expand)pubOpts := opts.Sub("publisher")
expand = pubOpts.Expand("contact")
fmt.Println("Expand publisher.contact:", expand)// Output:
// Expand author: true
// Expand category: false
// Expand publisher: true
// Expand publisher.contact: true
```