Skip to content

Commit

Permalink
Merge pull request #20 from daniel-yeow/fix-generator
Browse files Browse the repository at this point in the history
Prepend identifiers with _ when they begin with digit.
  • Loading branch information
lwlee2608 authored Jul 17, 2024
2 parents 7ebcbd0 + cc020a7 commit 7b6fd11
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/dict_generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"os"
"strings"
"unicode"

"github.com/fiorix/go-diameter/v4/diam/dict"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 7b6fd11

Please sign in to comment.