PROJECT_NAME := "connection-checker"
PKG := "gitlab.schukai.com/oss/utilities/network/connection-checker"
PKG_LIST := $(shell go list ${PKG}/... )
GO_FILES := $(shell find . -name '*.go')

GOCMD=go
GOBUILD=$(GOCMD) build 
GOCLEAN=$(GOCMD) clean 
GOTEST=$(GOCMD) test 
GOVET=$(GOCMD) vet  
GOGET=$(GOCMD) get 
GOFMT=$(GOCMD) fmt 
GODOC=$(GOCMD) fmt 
GOLINT=golint 

default: help

help:   ## show this help
	@echo 'usage: make [target] ...'
	@echo ''
	@echo 'targets:'
	@egrep '^(.+)\:\ .*##\ (.+)' ${MAKEFILE_LIST} | sed 's/:.*##/#/' | column -t -c 2 -s '#'

clean:  ## go clean
	$(GOCLEAN)

clean-all:  ## remove all generated artifacts and clean all build artifacts
	$(GOCLEAN) -i ./...

lint:   ## run go lint on the source files
	$(GOLINT) -set_exit_status .

doc:    ## generate godocs and start a local documentation webserver on port 8085
	godoc -http=:8085 -index

fmt:    ## format the go source files
	$(GOFMT) .

all:    ## clean, format and build
	make clean-all
	make fmt
	make build

build:
	mkdir -p bin
	$(GOCMD) build -o bin/nck 
	sudo setcap cap_net_raw+ep bin/nck