https://github.com/spatialcurrent/go-try-get
Wraps reflect to provide a standard abstraction layer to get named values from objects.
https://github.com/spatialcurrent/go-try-get
go golang reflection
Last synced: 6 days ago
JSON representation
Wraps reflect to provide a standard abstraction layer to get named values from objects.
- Host: GitHub
- URL: https://github.com/spatialcurrent/go-try-get
- Owner: spatialcurrent
- License: mit
- Created: 2018-10-18T14:49:42.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2021-11-30T13:53:00.000Z (about 4 years ago)
- Last Synced: 2024-06-21T03:15:25.419Z (over 1 year ago)
- Topics: go, golang, reflection
- Language: Go
- Homepage: https://pkg.go.dev/github.com/spatialcurrent/go-try-get
- Size: 27.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://circleci.com/gh/spatialcurrent/go-try-get/tree/main)
[](https://goreportcard.com/report/github.com/spatialcurrent/go-try-get)
[](https://pkg.go.dev/github.com/spatialcurrent/go-try-get)
[](https://github.com/spatialcurrent/go-try-get/blob/main/LICENSE)
# go-try-get
# Description
**go-try-get** aka (GTG) is a package that wraps around the [reflect](https://pkg.go.dev/reflect) package to provide a standard abstraction layer for getting values by name from objects (structs, maps, and single-value "property" functions). GTG is used by:
- [go-dfl](https://github.com/spatialcurrent/go-dfl) and
- [railgun](https://github.com/spatialcurrent/railgun).
For example, with GTG, you can provide a single pathways for an API to process structs and maps, allowing automated structured input from systems, as well as user-based input unmarshaled from JSON.
# Usage
**Go**
You can import **go-try-get** as a library with:
```
import (
"github.com/spatialcurrent/go-try-get/pkg/gtg"
)
```
See [gtg](https://pkg.go.dev/github.com/spatialcurrent/go-try-get/pkg/gtg) in the docs for information on how to use Go API.
# Testing
To run Go tests using `make test` or (`bash scripts/test.sh`), which runs unit tests, `go vet`, `go vet with shadow`, [errcheck](https://github.com/kisielk/errcheck), [staticcheck](https://staticcheck.io/), and [misspell](https://github.com/client9/misspell).
# Contributing
[Spatial Current, Inc.](https://spatialcurrent.io) is currently accepting pull requests for this repository. We'd love to have your contributions! Please see [Contributing.md](https://github.com/spatialcurrent/go-try-get/blob/main/CONTRIBUTING.md) for how to get started.
# License
This work is distributed under the **MIT License**. See **LICENSE** file.