https://github.com/codegold79/mutastruct
Use reflect package to do atypical changes to struct types.
https://github.com/codegold79/mutastruct
Last synced: 5 months ago
JSON representation
Use reflect package to do atypical changes to struct types.
- Host: GitHub
- URL: https://github.com/codegold79/mutastruct
- Owner: codegold79
- Created: 2022-12-17T00:39:58.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-17T02:24:33.000Z (over 3 years ago)
- Last Synced: 2024-06-20T12:42:17.261Z (almost 2 years ago)
- Language: Go
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mutastruct
Use the reflect package to make changes to a struct in an atypical manner.
To use, import the mutastruct package.
Call the following function to set a struct field.
```go
func Set(anyStruct any, fieldName string, setting any) error {
...
}
```
The first argument must be a pointer to a struct.
The last parameter, `setting`, is the desired value of the field specified by `fieldName` (the second parameter).
The `setting` argument must be the same type as the field you wish to change.