From 4d618b892b551a7f71f28db65a917c6405ac5997 Mon Sep 17 00:00:00 2001 From: Karan Sharma Date: Fri, 18 Dec 2020 20:18:28 +0530 Subject: [PATCH] fix: Make a separate cmd/doggo package for main files Closes https://github.com/mr-karan/doggo/issues/1 --- .goreleaser.yml | 2 +- Makefile | 13 +++++-------- README.md | 8 ++++++++ cmd/{ => doggo}/cli.go | 0 cmd/{ => doggo}/help.go | 0 cmd/{ => doggo}/hub.go | 0 cmd/{ => doggo}/lookup.go | 0 cmd/{ => doggo}/nameservers.go | 0 cmd/{ => doggo}/output.go | 0 cmd/{ => doggo}/parse.go | 0 cmd/{ => doggo}/resolver.go | 0 11 files changed, 14 insertions(+), 9 deletions(-) rename cmd/{ => doggo}/cli.go (100%) rename cmd/{ => doggo}/help.go (100%) rename cmd/{ => doggo}/hub.go (100%) rename cmd/{ => doggo}/lookup.go (100%) rename cmd/{ => doggo}/nameservers.go (100%) rename cmd/{ => doggo}/output.go (100%) rename cmd/{ => doggo}/parse.go (100%) rename cmd/{ => doggo}/resolver.go (100%) diff --git a/.goreleaser.yml b/.goreleaser.yml index a838490..13296c7 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -16,7 +16,7 @@ builds: - 7 ldflags: - -s -w -X "main.buildVersion={{ .Tag }} ({{ .ShortCommit }} {{ .Date }})" - dir: ./cmd/ + dir: ./cmd/doggo/ archives: - format: tar.gz diff --git a/Makefile b/Makefile index 1b2b33e..774cd76 100644 --- a/Makefile +++ b/Makefile @@ -1,24 +1,21 @@ -DOGGO-BIN := doggo +BIN := ./bin/doggo HASH := $(shell git rev-parse --short HEAD) BUILD_DATE := $(shell date '+%Y-%m-%d %H:%M:%S') VERSION := ${HASH} .PHONY: build -build: ## Build the doggo binary - mkdir -p bin/; \ - cd cmd/; \ - go build -ldflags="-X 'main.buildVersion=${VERSION}' -X 'main.buildDate=${BUILD_DATE}'" -o ${DOGGO-BIN} ./... && \ - mv ${DOGGO-BIN} ../bin/${DOGGO-BIN} +build: + go build -o ${BIN} -ldflags="-X 'main.buildVersion=${VERSION}' -X 'main.buildDate=${BUILD_DATE}'" ./cmd/doggo/ .PHONY: run run: build ## Build and Execute the binary after the build step - ./bin/${DOGGO-BIN} + ${BIN} .PHONY: clean clean: go clean - - rm -f ./bin/${BIN} + - rm -f ${BIN} .PHONY: lint lint: diff --git a/README.md b/README.md index 3e6ba96..f5aa1e6 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,14 @@ You can supply all arguments to the CLI directly to `docker run` command. Eg: $ sudo snap install doggo ``` +### From Source + +You need to have `go` installed in your system. + +```bash +$ go get github.com/mr-karan/doggo/cmd/doggo +``` + **NOTE**: Since the [confinement](https://snapcraft.io/docs/snap-confinement) mode is strict as of now, it cannot access your host's `/etc/resolv.conf`. I'll be making a request in the Snap forums soon so that it can be manually reviewed and allowed to use `--classic`. Until then, please specify a namesever manually if using `snap`. diff --git a/cmd/cli.go b/cmd/doggo/cli.go similarity index 100% rename from cmd/cli.go rename to cmd/doggo/cli.go diff --git a/cmd/help.go b/cmd/doggo/help.go similarity index 100% rename from cmd/help.go rename to cmd/doggo/help.go diff --git a/cmd/hub.go b/cmd/doggo/hub.go similarity index 100% rename from cmd/hub.go rename to cmd/doggo/hub.go diff --git a/cmd/lookup.go b/cmd/doggo/lookup.go similarity index 100% rename from cmd/lookup.go rename to cmd/doggo/lookup.go diff --git a/cmd/nameservers.go b/cmd/doggo/nameservers.go similarity index 100% rename from cmd/nameservers.go rename to cmd/doggo/nameservers.go diff --git a/cmd/output.go b/cmd/doggo/output.go similarity index 100% rename from cmd/output.go rename to cmd/doggo/output.go diff --git a/cmd/parse.go b/cmd/doggo/parse.go similarity index 100% rename from cmd/parse.go rename to cmd/doggo/parse.go diff --git a/cmd/resolver.go b/cmd/doggo/resolver.go similarity index 100% rename from cmd/resolver.go rename to cmd/doggo/resolver.go