-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: develop
Are you sure you want to change the base?
Conversation
TheRealSpaceShip
commented
Apr 4, 2024
- Remove all except formatSubdomain and unquote
- Improve curly template encodings like base64, first, etc.
- Improve utils Keys and SortedKeys
e46000f
to
1078ec1
Compare
- Remove all except formatSubdomain and unquote - Improve curly template encodings like base64, first, etc. - Improve utils Keys and SortedKeys
1078ec1
to
9609cc9
Compare
There was a problem hiding this 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){ |
There was a problem hiding this comment.
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]) |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?