aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-09-15 01:47:52 +0200
committerPřemysl Eric Janouch <p@janouch.name>2022-09-15 01:51:40 +0200
commitb53fc1918fe410d08c3ea400d61d822fe2facc89 (patch)
tree335967c9fb2896104e623adeb61785ea9cd4e2ff
parent92f2f6895b41ecb60e3aaf59e3ea5bc20d9cd314 (diff)
downloadxK-b53fc1918fe410d08c3ea400d61d822fe2facc89.tar.gz
xK-b53fc1918fe410d08c3ea400d61d822fe2facc89.tar.xz
xK-b53fc1918fe410d08c3ea400d61d822fe2facc89.zip
xP: fix log JSON serialization
-rw-r--r--xC-gen-proto-go.awk9
1 files changed, 9 insertions, 0 deletions
diff --git a/xC-gen-proto-go.awk b/xC-gen-proto-go.awk
index eb08477..a2244b5 100644
--- a/xC-gen-proto-go.awk
+++ b/xC-gen-proto-go.awk
@@ -100,6 +100,7 @@ function codegen_begin() {
print "package main"
print ""
print "import ("
+ print "\t`encoding/base64`"
print "\t`encoding/binary`"
print "\t`encoding/json`"
print "\t`errors`"
@@ -274,6 +275,14 @@ function codegen_struct_field_marshal(d, cg, camel, f, marshal) {
return
}
+ if (d["type"] == "u8") {
+ append(cg, "marshal",
+ "\tb = append(b, `,\"" decapitalize(camel) "\":\"`...)\n" \
+ "\tb = append(b, base64.StdEncoding.EncodeToString(" f ")...)\n" \
+ "\tb = append(b, '\"')\n")
+ return
+ }
+
if (CodegenIsMarshaler[d["type"]])
marshal = f "[i].MarshalJSON()"
else