-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
bugunexpected problem or unintended behaviorunexpected problem or unintended behavior
Description
Relevant telegraf.conf
Tried out function directly with the input, so, no telegraf.conf necessary.
Logs from Telegraf
Tried out function directly with the input, so, no logs necessary.
System info
The latest telegraf master repo version
Docker
No response
Steps to reproduce
` package main
import "fmt"
import "unicode"
// SnakeCase converts the given string to snake case following the Golang format:
// acronyms are converted to lower-case and preceded by an underscore.
func SnakeCase(in string) string {
runes := []rune(in)
length := len(runes)
var out []rune
for i := 0; i < length; i++ {
if i > 0 && unicode.IsUpper(runes[i]) && ((i+1 < length && unicode.IsLower(runes[i+1])) || unicode.IsLower(runes[i-1])) {
out = append(out, '_')
}
out = append(out, unicode.ToLower(runes[i]))
}
return string(out)
}
func main() {
fmt.Println(SnakeCase("ConsumedLCUs"))
}
`
% go run testSnakeCase.go consumed_lc_us %
Expected behavior
consumed_lcus
Actual behavior
consumed_lc_us
Additional info
No response
Metadata
Metadata
Assignees
Labels
bugunexpected problem or unintended behaviorunexpected problem or unintended behavior