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

Use sprig instead of custom go template functions #21 #95

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

TheRealSpaceShip
Copy link
Contributor

  • Remove all except formatSubdomain and unquote
  • Improve curly template encodings like base64, first, etc.
  • Improve utils Keys and SortedKeys

@TheRealSpaceShip TheRealSpaceShip added enhancement New feature or request debt Technical debt labels Apr 4, 2024
@TheRealSpaceShip TheRealSpaceShip self-assigned this Apr 4, 2024
@TheRealSpaceShip TheRealSpaceShip linked an issue Apr 4, 2024 that may be closed by this pull request
7 tasks
@arkadijs arkadijs force-pushed the 21-better-range-support-for-go-template branch from e46000f to 1078ec1 Compare July 24, 2024 11:15
- Remove all except formatSubdomain and unquote
- Improve curly template encodings like base64, first, etc.
- Improve utils Keys and SortedKeys
@TheRealSpaceShip TheRealSpaceShip force-pushed the 21-better-range-support-for-go-template branch from 1078ec1 to 9609cc9 Compare August 5, 2024 13:52
Copy link
Collaborator

@arkadijs arkadijs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM otherwise.

return url.Scheme, nil
}

var encodingsMap = map[string]func(interface{}) (interface{}, error){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like variable name doesn't match intention anymore. Now the variable contains parseURL which is not an encoding by any stretch. Also the corresponding message at call site.
Suggest converter or just function.

} else if arg1.Kind() == reflect.String {
size, _ = strconv.Atoi(arg1.String())
} else {
return "", fmt.Errorf("Argument type %T not yet supported", args[1])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"argument for consistency.

// Third optional argument is a delimiter (default is '-')
func formatSubdomain(args ...interface{}) (string, error) {
if len(args) == 0 {
return "", fmt.Errorf("hostname expects at least one argument")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May as well use errors.New().

@@ -369,27 +371,22 @@ func Index(list []string, search string) int {
return index
}

func SortedKeys(m map[string]string) []string {
func Keys[K cmp.Ordered, V any](m map[K]V) []K {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constrained on Ordered but not used to sort the result?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debt Technical debt enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better range support for go template
2 participants