MM-32248 streamline serialization auto-generation (#16780)

* streamline serialization auto-gen
Этот коммит содержится в:
Doug Lauder
2021-01-24 23:58:26 -05:00
коммит произвёл GitHub
родитель c2316c15f3
Коммит b932e0fb25
9 изменённых файлов: 1533 добавлений и 1784 удалений

Просмотреть файл

@@ -576,7 +576,7 @@ vet: ## Run mattermost go vet specific checks
echo "mattermost-govet is not installed. Please install it executing \"GO111MODULE=off GOBIN=$(PWD)/bin go get -u github.com/mattermost/mattermost-govet\""; \
exit 1; \
fi;
@VET_CMD="-license -structuredLogging -inconsistentReceiverName -inconsistentReceiverName.ignore=serialized_gen.go -tFatal"; \
@VET_CMD="-license -structuredLogging -inconsistentReceiverName -inconsistentReceiverName.ignore=session_serial_gen.go,team_member_serial_gen.go,user_serial_gen.go -tFatal"; \
if ! [ -z "${MM_VET_OPENSPEC_PATH}" ] && [ -f "${MM_VET_OPENSPEC_PATH}" ]; then \
VET_CMD="$$VET_CMD -openApiSync -openApiSync.spec=$$MM_VET_OPENSPEC_PATH"; \
else \
@@ -591,10 +591,16 @@ endif
gen-serialized: ## Generates serialization methods for hot structs
# This tool only works at a file level, not at a package level.
# So you would need to move the structs that need to be serialized temporarily
# to session.go and run the tool.
# There will be some warnings about "unresolved identifiers",
# but that is because of the above problem. Since we are generating
# methods for all the relevant files at a package level, all
# identifiers will be resolved. An alternative to remove the warnings
# would be to temporarily move all the structs to the same file,
# but that involves a lot of manual work.
$(GO) get -modfile=go.tools.mod github.com/tinylib/msgp
$(GOBIN)/msgp -file=./model/session.go -tests=false -o=./model/serialized_gen.go
$(GOBIN)/msgp -file=./model/session.go -tests=false -o=./model/session_serial_gen.go
$(GOBIN)/msgp -file=./model/user.go -tests=false -o=./model/user_serial_gen.go
$(GOBIN)/msgp -file=./model/team_member.go -tests=false -o=./model/team_member_serial_gen.go
todo: ## Display TODO and FIXME items in the source code.
@! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime TODO