From 968111b0a8d63dbc9766c9e1a93782a096100559 Mon Sep 17 00:00:00 2001 From: Bertrand Lefort Date: Sun, 14 Jan 2024 12:06:26 -0500 Subject: [PATCH 1/2] fix int to str conversion --- DTD/DTD.go | 5 +++-- scanner/sentence.go | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/DTD/DTD.go b/DTD/DTD.go index 85d0cca..ce0a1c0 100644 --- a/DTD/DTD.go +++ b/DTD/DTD.go @@ -8,7 +8,7 @@ // // Found this reference very usefull: https://xmlwriter.net/xml_guide/attlist_declaration.shtml // -// This is a simplified implementation +// # This is a simplified implementation // // This package offers one struct per DTD blocks // Each struct will implements the IDTDBlock @@ -16,6 +16,7 @@ package DTD import ( + "fmt" "strings" ) @@ -96,7 +97,7 @@ func Translate(i int) string { case NOTATION: return "Notation" default: - panic("Unknown type" + string(i) + " requested") + panic("Unknown type" + fmt.Sprintf("%d", i) + " requested") } } diff --git a/scanner/sentence.go b/scanner/sentence.go index c7d15da..e980fa8 100644 --- a/scanner/sentence.go +++ b/scanner/sentence.go @@ -1,6 +1,7 @@ package scanner import ( + "fmt" "strings" "github.com/blefort/DTDParser/DTD" @@ -39,7 +40,7 @@ func newsentence(start string, end string, Log *zap.SugaredLogger) *sentence { func (se *sentence) MarshalLogObject(enc zapcore.ObjectEncoder) error { for i, w := range se.words { - enc.AddString("Word "+string(i), w.Read()) + enc.AddString(fmt.Sprintf("Word %d", string(i)), w.Read()) } return nil } From d292472ab54429bd40b11b20bd65417ea031013d Mon Sep 17 00:00:00 2001 From: Bertrand Lefort Date: Sat, 20 Jan 2024 19:46:29 -0500 Subject: [PATCH 2/2] fix fmt.sprintf call --- scanner/sentence.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scanner/sentence.go b/scanner/sentence.go index e980fa8..b383bd4 100644 --- a/scanner/sentence.go +++ b/scanner/sentence.go @@ -40,7 +40,7 @@ func newsentence(start string, end string, Log *zap.SugaredLogger) *sentence { func (se *sentence) MarshalLogObject(enc zapcore.ObjectEncoder) error { for i, w := range se.words { - enc.AddString(fmt.Sprintf("Word %d", string(i)), w.Read()) + enc.AddString(fmt.Sprintf("Word %d", i), w.Read()) } return nil }