From 5404c343a04096c359e0ac69888a90a209de5375 Mon Sep 17 00:00:00 2001 From: Prabhjot Singh Sethi Date: Tue, 8 Apr 2025 20:18:52 +0000 Subject: [PATCH] Enable linter for the code Signed-off-by: Prabhjot Singh Sethi --- Makefile | 7 ++++++- db/source.go | 2 +- scripts/dev-setup-ubuntu.sh | 5 ++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index e548ae6..f0500ce 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,10 @@ ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) .PHONY: all -all: go-format go-vet setup-mongodb-env +all: go-format go-vet go-lint setup-mongodb-env +test: go-format go-vet go-lint + go test -v ./... setup-mongodb-env: ${ROOT_DIR}/scripts/mongodb/run-mongodb-dev.sh ${ROOT_DIR}/scripts/mongodb/run-mongoexpress.sh @@ -19,3 +21,6 @@ go-format: go-vet: go vet ./... + +go-lint: + golangci-lint run diff --git a/db/source.go b/db/source.go index da68cbb..e0234bb 100644 --- a/db/source.go +++ b/db/source.go @@ -39,7 +39,7 @@ func SetSourceIdentifier(identifier string) bool { } // for internal use only, it will also make source identifier in use -func getSourceIdentifier() string { +func GetSourceIdentifier() string { sourceIdentifierLock.RLock() defer sourceIdentifierLock.RUnlock() sourceIdentifierUsed = true diff --git a/scripts/dev-setup-ubuntu.sh b/scripts/dev-setup-ubuntu.sh index 403a9af..a3bec78 100755 --- a/scripts/dev-setup-ubuntu.sh +++ b/scripts/dev-setup-ubuntu.sh @@ -16,4 +16,7 @@ sudo tar -C /usr/local -xzf ${GOLANG_PACKAGE} rm -rf ${GOLANG_PACKAGE} echo "export GOPATH=\$HOME/go" >> ~/.bashrc echo "export PATH=\$PATH:/usr/local/go/bin:\$HOME/go/bin" >> ~/.bashrc -source ~/.bashrc \ No newline at end of file +source ~/.bashrc + +# install golang lint cli +go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.0.2 \ No newline at end of file