hashicorp / hashicorp/go-argmapper
Add ability to provide named/typed args from a struct
- Dominant language
- Go
- Stars
- 125
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
This is the reverse of the usage of `argmapper.Struct` embedding.
I'd like to be able to let users pass a struct and then take all the exported fields of the struct and specify them as `Named` / `Typed` parameters (potentially reusing the same field tags as `argmapper.Struct` or some other configuration options).
```go
target, err := argmapper.NewFunc(func(w io.Writer) {
// ... use the writer ...
})
myStruct := &struct{
W io.Writer
}{ ... }
result := target.Call(argmapper.FromStruct(myStruct)) // FromStruct is the new method for the Arg
if result.Err() != nil {
panic(result.Err())
}
```
(written up from a conversation outside of GitHub)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.