#############################################################################################
#############################################################################################
##
## BUILD GO
##
#############################################################################################
#############################################################################################

ifeq ($(GO),)
  $(error $(ERRORMARKER) Go is not defined, check your Makefile if go.mk is included)
endif

GO_RELEASE_PACKAGE_NAME ?= main

.PHONY: compile
## Compiling for every OS and Platform
compile: next-patch-version
	$(ECHOMARKER) "Compiling for every OS and Platform"
	$(ECHO) "Version: $(PROJECT_VERSION)"
	$(ECHO) "Build: $(PROJECT_BUILD_DATE)"
	$(QUIET) $(DEVELOPMENT_SCRIPTS_PATH)/go-compile.sh $(SOURCE_PATH) $(BUILD_PATH) $(COMPONENT_SLUG) $(GO_RELEASE_PACKAGE_NAME) $(PROJECT_VERSION) $(PROJECT_BUILD_DATE)


.PHONY: go-lint
## Lint the files
go-lint: 
	$(QUIET) $(GOLINT) -set_exit_status ${PKG_LIST}

.PHONY: go-test	
## Run unittests
go-test: 
	$(QUIET) $(GO) test -short ${PKG_LIST}

.PHONY: go-race
## Run data race detector
go-race: go-dep 
	$(QUIET) $(GO) test -race -short ${PKG_LIST}

.PHONY: go-msan
## Run memory sanitizer
go-msan: go-dep 
	$(QUIET) $(GO) test -msan -short ${PKG_LIST}

.PHONY: go-coverage
## Generate global code coverage report
go-coverage: 
	$(QUIET) $(DEVELOPMENT_SCRIPTS_PATH)/go-coverage.sh $(SOURCE_PATH) $(DEVELOPMENT_PATH)/report ;

.PHONY: go-cover-html
## Generate global code coverage report in HTML
go-cover-html: 
	$(QUIET) $(DEVELOPMENT_SCRIPTS_PATH)/go-coverage.sh $(SOURCE_PATH) $(DEVELOPMENT_PATH)/report html;

.PHONY: go-dep
## Get the dependencies
go-dep:
	$(QUIET) cd $(SOURCE_PATH); $(GO) get -v -d ./... ; cd -;