https://github.com/yaronsumel/filler
fill struct data easily with fill tags
https://github.com/yaronsumel/filler
Last synced: 9 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 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-10T08:03:38.000Z (over 8 years ago)
- Last Synced: 2024-07-31T20:53:34.904Z (over 1 year 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-cn - filler
- 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 - filler - small utility to fill structs using "fill" tag. (Utilities / Advanced Console UIs)
- awesome-go - filler - small utility to fill structs using "fill" tag. (Utilities / Utility/Miscellaneous)
- fucking-awesome-go - filler - small utility to fill structs using "fill" tag. (Utilities / Utility/Miscellaneous)
- awesome-go - filler - | - | - | (Utilities / HTTP Clients)
- awesome-go-plus - filler - small utility to fill structs using "fill" tag.  (Utilities / Utility/Miscellaneous)
- awesome-go - filler - small utility to fill structs using "fill" tag. (Utilities / Utility/Miscellaneous)
- awesome-go - filler - small utility to fill structs using "fill" tag. - :arrow_down:1 - :star:10 (Utilities / HTTP Clients)
- awesome-go-with-stars - filler - small utility to fill structs using "fill" tag. (Utilities / Utility/Miscellaneous)
- awesome-go - filler - small utility to fill structs using "fill" tag. (Utilities / Utility/Miscellaneous)
- awesome-go - filler - small utility to fill structs using "fill" tag. (Utilities / Utility/Miscellaneous)
- awesome-Char - filler - small utility to fill structs using "fill" tag. (Utilities / HTTP Clients)
- awesome-go-cn - filler
- awesome-go - filler - small utility to fill structs using "fill" tag. (Utilities / HTTP Clients)
- awesome-go-cn - filler
- awesome-go-zh - filler
- awesome-go-extra - filler - 04-05T08:14:04Z|2017-04-10T08:03:38Z| (Utilities / Fail injection)
- awesome-go - filler - small utility to fill structs using "fill" tag. (Utilities / <span id="高级控制台用户界面-advanced-console-uis">高级控制台用户界面 Advanced Console UIs</span>)
- awesome-go-cn - filler
README
# filler [](https://goreportcard.com/report/github.com/yaronsumel/filler) [](https://travis-ci.org/yaronsumel/filler) [](https://godoc.org/github.com/yaronsumel/filler)
###### small util to fill gaps in your structs
Installation
------
```bash
$ go get github.com/yaronsumel/filler
```
[Usage](https://github.com/yaronsumel/filler/blob/master/example/example.go)
------
```go
package main
import (
"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) #####