From cc020a7019432b773879c29401dfa7996ceab835 Mon Sep 17 00:00:00 2001 From: Daniel Yeow Date: Wed, 17 Jul 2024 18:32:25 +0800 Subject: [PATCH] Prepend identifiers with _ when they begin with digit. --- cmd/dict_generator/main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/dict_generator/main.go b/cmd/dict_generator/main.go index dd758be..607b587 100644 --- a/cmd/dict_generator/main.go +++ b/cmd/dict_generator/main.go @@ -6,6 +6,7 @@ import ( "io" "os" "strings" + "unicode" "github.com/fiorix/go-diameter/v4/diam/dict" log "github.com/sirupsen/logrus" @@ -84,6 +85,9 @@ func PrintAvpCode(w io.Writer, parser *dict.Parser) { fmt.Fprintf(w, " // %s\n", app.Name) for _, avp := range app.AVP { name := strings.ReplaceAll(avp.Name, "-", "") + if len(name) != 0 && unicode.IsDigit(rune(name[0])) { + name = "_" + name + } fmt.Fprintf(w, " %-45s %d,\n", name+":", avp.Code) } }