diff --git a/.gitignore b/.gitignore index 8d475c0..629e407 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ *.dll *.so *.dylib +bin/ +.env/ # Test binary, built with `go test -c` *.test @@ -11,6 +13,6 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out -# Dependency directories (remove the comment below to include it) -# vendor/ +# Dependency directories +vendor/ plugins/ \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..8fef2d3 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Launch executable", + "type": "go", + "request": "launch", + "mode": "exec", + "program": "${workspaceRoot}/bin/OpenSkins", + "preLaunchTask": "compile", + "internalConsoleOptions": "openOnSessionStart" + } + ] +} + diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..286bf2f --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,35 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "compile", + "type": "shell", + "command": "make compile" + }, + { + "label": "install", + "type": "shell", + "command": "make install" + }, + { + "label": "clean", + "type": "shell", + "command": "make clean" + }, + { + "label": "build", + "type": "shell", + "command": "make build" + }, + { + "label": "run", + "type": "shell", + "command": "make run" + }, + { + "label": "test", + "type": "shell", + "command": "make test" + } + ] +} \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6e26e7a --- /dev/null +++ b/Makefile @@ -0,0 +1,82 @@ +#include .env + +PROJECTNAME="OpenSkins" + +# Go related variables. +GOBASE=$(shell pwd) +GOPATH=$(GOBASE)/vendor:$(GOBASE):/home/azer/code/golang # You can remove or change the path after last colon. +GOBIN=$(GOBASE)/bin +GOFILES=$(wildcard *.go) + +# Redirect error output to a file, so we can show it in development mode. +STDERR=/tmp/.$(PROJECTNAME)-stderr.txt + +# PID file will store the server process id when it's running on development mode +PID=/tmp/.$(PROJECTNAME)-api-server.pid + +# Make is verbose in Linux. Make it silent. +MAKEFLAGS += --silent + +go-compile: go-clean go-get go-build + +go-build: + @echo " > Building binary..." + @GOPATH=$(GOPATH) GOBIN=$(GOBIN) go build -o $(GOBIN)/$(PROJECTNAME) $(GOFILES) + +go-generate: + @echo " > Generating dependency files..." + @GOPATH=$(GOPATH) GOBIN=$(GOBIN) go generate $(generate) + +go-get: + @echo " > Checking if there is any missing dependencies..." + @GOPATH=$(GOPATH) GOBIN=$(GOBIN) go get $(get) + +go-install: + @GOPATH=$(GOPATH) GOBIN=$(GOBIN) go install $(GOFILES) + +go-clean: + @echo " > Cleaning build cache" + @GOPATH=$(GOPATH) GOBIN=$(GOBIN) go clean + +go-test: + @echo " > Running tests..." + @GOPATH=$(GOPATH) GOBIN=$(GOBIN) go test + +go-run: + @echo " > Running ${PROJECTNAME}" + @-(cd $(GOBIN); ./$(PROJECTNAME)) + + +## install: downloads and installs dependencies +install: go-get + +## clean: test +clean: + @(MAKEFILE) go-clean + +## compile: cleans project, installs dependencies, and builds project +compile: + @-touch $(STDERR) + @-rm $(STDERR) + @-$(MAKE) -s go-compile 2> $(STDERR) + @cat $(STDERR) | sed -e '1s/.*/\nError:\n/' | sed 's/make\[.*/ /' | sed "/^/s/^/ /" 1>&2 + +## watch: Runs go clean +watch: + @yolo -i . -e vendor -e bin -c $(run) + +## build: Runs go build +build: go-build + +## run: Compiles and executes project binary +run: go-compile go-run + +## test: Run unit tests +test: go-test + +## help: Displays help text for make commands +.DEFAULT_GOAL := help +all: help +help: Makefile + @echo " Choose a command run in "$(PROJECTNAME)":" + @sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /' \ No newline at end of file diff --git a/main.go b/main.go index 982d552..0defc5d 100644 --- a/main.go +++ b/main.go @@ -17,7 +17,8 @@ func main() { pluginFiles, err := pluginmanager.GetPlugins(plugindirectory) if err != nil { - log.Warningln(fmt.Sprintf("Failed to read plugins directory: %v", err.Error())) + log.Fatalln(fmt.Sprintf("Failed to read plugins directory: %v", err.Error())) + os.Exit(1) } loadedPlugins := []*plugin.Plugin{}