Skip to content

Commit

Permalink
remove DefaultStructRowsViewer and DefaultStructRowsViewerIgnoreUntagged
Browse files Browse the repository at this point in the history
  • Loading branch information
ungerik committed Jan 29, 2024
1 parent 2e06bcb commit 7f484f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
17 changes: 3 additions & 14 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,22 @@ var (
// DefaultStructFieldNaming provides the default StructFieldNaming
// using "col" as title tag, ignores "-" titled fields,
// and uses SpacePascalCase for untagged fields.
// Implements the Viewer interface.
DefaultStructFieldNaming = StructFieldNaming{
Tag: "col",
Ignore: "-",
Untagged: SpacePascalCase,
}

// DefaultStructRowsViewer provides the default StructRowsViewer
// using "col" as title tag, ignores "-" titled fields,
// and uses SpacePascalCase for untagged fields.
DefaultStructRowsViewer = &StructRowsViewer{
StructFieldNaming: DefaultStructFieldNaming,
}

// DefaultStructFieldNamingIgnoreUntagged provides the default StructFieldNaming
// using "col" as title tag, ignores "-" titled as well as untitled fields.
// Implements the Viewer interface.
DefaultStructFieldNamingIgnoreUntagged = StructFieldNaming{
Tag: "col",
Ignore: "-",
Untagged: UseTitle("-"),
}

// DefaultStructRowsViewerIgnoreUntagged provides the default StructRowsViewer
// using "col" as title tag, ignores "-" titled as well as untitled fields.
DefaultStructRowsViewerIgnoreUntagged = &StructRowsViewer{
StructFieldNaming: DefaultStructFieldNamingIgnoreUntagged,
}

// SelectViewer selects the best matching Viewer implementation
// for the passed table type.
// By default it returns a StringsViewer for a [][]string table
Expand All @@ -45,7 +34,7 @@ var (
if _, ok := table.([][]string); ok {
return new(StringsViewer), nil
}
return DefaultStructRowsViewer, nil
return &DefaultStructFieldNaming, nil
}

noTagsStructRowsViewer StructRowsViewer
Expand Down
4 changes: 4 additions & 0 deletions structfieldnaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ import (
"strings"
)

var _ Viewer = new(StructFieldNaming)

// StructFieldNaming defines how struct fields
// are mapped to column titles as used by View.
//
// nil is a valid value for *StructFieldNaming
// and is equal to the zero value
// which will use all exported struct fields
// with their field name as column title.
//
// StructFieldNaming implements the Viewer interface.
type StructFieldNaming struct {
// Tag is the struct field tag to be used as column title.
// If Tag is empty, then every struct field will be treated as untagged.
Expand Down

0 comments on commit 7f484f9

Please sign in to comment.