From bd667c0fc14e48266a84e72ffac3ad1dbafb0a12 Mon Sep 17 00:00:00 2001 From: rasmus Date: Tue, 8 Nov 2022 08:57:39 +0200 Subject: [PATCH] improve direct string warning --- cmd/mongo_struct.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/mongo_struct.go b/cmd/mongo_struct.go index 15d959a..91f4802 100644 --- a/cmd/mongo_struct.go +++ b/cmd/mongo_struct.go @@ -43,6 +43,9 @@ const ( mLogKeyHostId = mLogKeyHostInfo + "." + mLogKeyId ) +// Don't use direct strings in bson types. Use the constants as keys. +// This ensures keys (and subkeys) are consistent, at least within the package. + const ( mLogKeyHostInfo = "host_info" mLogKeyId = "id" @@ -59,7 +62,6 @@ const ( // not using marshal, since it is <0.1x performance func (l *mLog) toBson() bson.M { - // DO NOT USE QUOTED STRINGS! Move them to const and use variable instead return bson.M{ mLogKeyHostInfo: bson.M{ mLogKeyId: l.HostInfo.Id,