Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: README.md #17

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 30 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,35 @@ func main() {
## 🛠️Details

### XsvWrite

| FieldName | Type | Description |
|-----------------|-------------------|---------------------------------------------------------------|
| TagName | string | key in the struct field's tag to scan |
| TagSeparator | string | separator string for multiple csv tags in struct fields |
| OmitHeaders | bool | whether to output headers to csv or not |
| SelectedColumns | []string | slice of field names(which is set in "TagName" tag) to output |
| SortOrder | []uint | column sort order |
| HeaderModifier | map[string]string | map to dynamically change headers |
- **TagName**: `string`
- Key in the struct field's tag to scan
- **TagSeparator**: `string`
- Separator string for multiple CSV tags in struct fields
- **OmitHeaders**: `bool`
- Whether to output headers to CSV or not
- **SelectedColumns**: `[]string`
- Slice of field names (which is set in "TagName" tag) to output
- **SortOrder**: `[]uint`
- Column sort order
- **HeaderModifier**: `map[string]string`
- Map to dynamically change headers
- **OnRecord** `func(T) T`
- Callback function to be called on each record

### XsvRead

| FieldName | Type | Description |
|-------------------------------------------------|---------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| TagName | string | key in the struct field's tag to scan |
| TagSeparator | string | separator string for multiple csv tags in struct fields |
| FailIfUnmatchedStructTags | bool | indicates whether it is considered an error when there is an unmatched struct tag. |
| FailIfDoubleHeaderNames | bool | indicates whether it is considered an error when a header name is repeated in the csv header. |
| ShouldAlignDuplicateHeadersWithStructFieldOrder | bool | indicates whether we should align duplicate CSV headers per their alignment in the struct definition. |
| NameNormalizer | Normalizer(func(string) string) | Normalizer is a function that takes and returns a string. It is applied to struct and header field values before they are compared. It can be used to alter names for comparison. For instance, you could allow case insensitive matching or convert '-' to '_'. |
- **TagName**: `string`
- Key in the struct field's tag to scan
- **TagSeparator**: `string`
- Separator string for multiple CSV tags in struct fields
- **FailIfUnmatchedStructTags**: `bool`
- Indicates whether it is considered an error when there is an unmatched struct tag.
- **FailIfDoubleHeaderNames**: `bool`
- Indicates whether it is considered an error when a header name is repeated in the CSV header.
- **ShouldAlignDuplicateHeadersWithStructFieldOrder**: `bool`
- Indicates whether duplicate CSV headers should be aligned per their order in the struct definition.
- **OnRecord** `func(T) T`
- Callback function to be called on each record
- **NameNormalizer**: `Normalizer(func(string) string)`
- Normalizer is a function that takes and returns a string. It is applied to struct and header field values before they are compared. It can be used to alter names for comparison. For instance, you could allow case-insensitive matching or convert '-' to '_'.
- **ErrorHandler**: `ErrorHandler(func(*csv.ParseError) bool)`
- ErrorHandler is a function that takes an error and handles it. It can be used to log errors or to panic.
Loading