Implement func mapper for parser reflection

This commit is contained in:
2024-11-26 11:46:15 -05:00
parent b97b24d394
commit 42bf0696d6
5 changed files with 416 additions and 15 deletions

View File

@ -2,6 +2,7 @@
CLIENT_PKG := ./cmd/eia-client
CLIENT_GEN_FILE := ./api/eiaapi.gen.go
GO_FORMATTER := gofumpt
IS_GNU_SED := $(shell sed --version >/dev/null 2>&1 && echo true || echo false)
.PHONY: all generate build install clean
@ -11,9 +12,15 @@ all: generate build
# Generate code
generate:
go generate ./...
# Fix errors in generated code
ifeq ($(IS_GNU_SED), true)
# Fix errors in generated code with GNU sed
sed -E -i 's/Total[[:space:]]+\*int/Total *string/g' $(CLIENT_GEN_FILE)
sed -E -i 's/Command[[:space:]]+\*\[\]string/Command *string/g' $(CLIENT_GEN_FILE)
else
# Fix errors in generated code with BSD sed
sed -E -i '' 's/Total[[:space:]]+\*int/Total *string/g' $(CLIENT_GEN_FILE)
sed -E -i '' 's/Command[[:space:]]+\*\[\]string/Command *string/g' $(CLIENT_GEN_FILE)
endif
# Pretty it up
$(GO_FORMATTER) -w $(CLIENT_GEN_FILE)