An open API service indexing awesome lists of open source software.

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.

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.