Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yaronsumel/filler
fill struct data easily with fill tags
https://github.com/yaronsumel/filler
Last synced: about 2 months ago
JSON representation
fill struct data easily with fill tags
- Host: GitHub
- URL: https://github.com/yaronsumel/filler
- Owner: yaronsumel
- License: mit
- Created: 2017-04-05T08:14:04.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-04-10T08:03:38.000Z (over 7 years ago)
- Last Synced: 2024-07-31T20:53:34.904Z (5 months ago)
- Language: Go
- Size: 19.5 KB
- Stars: 17
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - filler - small utility to fill structs using "fill" tag. (Utilities / Utility/Miscellaneous)
- awesome-go - filler - fill struct data easily with fill tags - ★ 14 (Utilities)
- awesome-go-extra - filler - 04-05T08:14:04Z|2017-04-10T08:03:38Z| (Utilities / Fail injection)
README
# filler [![Go Report Card](https://goreportcard.com/badge/github.com/yaronsumel/filler)](https://goreportcard.com/report/github.com/yaronsumel/filler) [![Build Status](https://travis-ci.org/yaronsumel/grapes.svg?branch=master)](https://travis-ci.org/yaronsumel/filler) [![GoDoc](https://godoc.org/github.com/yaronsumel/filler?status.svg)](https://godoc.org/github.com/yaronsumel/filler)
###### small util to fill gaps in your structsInstallation
------
```bash
$ go get github.com/yaronsumel/filler
```[Usage](https://github.com/yaronsumel/filler/blob/master/example/example.go)
------```go
package mainimport (
"fmt"
"github.com/yaronsumel/filler"
)type model struct {
UserID string
UserName string `fill:"UserNameFiller:UserID"`
}func init() {
filler.RegFiller("UserNameFiller", func(value interface{}) (interface{}, error) {
return "UserId" + value.(string), nil
})
}func main() {
m := &model{
UserID: "123",
}
fmt.Printf("%+v\n", m)
// should print `&{UserId:123 UserName:}`
filler.Fill(m)
// should print `&{UserId:123 UserName:UserId123}`
fmt.Printf("%+v\n", m)
}```
> ##### Written and Maintained by [@YaronSumel](https://twitter.com/yaronsumel) #####