From 7ee8736040bff44a5cd4e1516f65fafa7aca76a8 Mon Sep 17 00:00:00 2001 From: Maxim Baz Date: Mon, 9 Apr 2018 22:22:52 +0200 Subject: [PATCH] Initial boilerplate: go dep, good logger, makefile (#2) --- .editorconfig | 15 +++++++++++++++ .gitignore | 3 +++ Gopkg.lock | 30 ++++++++++++++++++++++++++++++ Gopkg.toml | 25 +++++++++++++++++++++++++ Makefile | 27 +++++++++++++++++++++++++++ main.go | 32 ++++++++++++++++++++++++++++++++ process.go | 5 +++++ 7 files changed, 137 insertions(+) create mode 100644 .editorconfig create mode 100644 Gopkg.lock create mode 100644 Gopkg.toml create mode 100644 Makefile create mode 100644 main.go create mode 100644 process.go diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f52b09b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.go] +indent_style = tab + +[Makefile] +indent_style = tab diff --git a/.gitignore b/.gitignore index e69de29..5be7bc2 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,3 @@ +/browserpass +/browserpass-* +vendor/ diff --git a/Gopkg.lock b/Gopkg.lock new file mode 100644 index 0000000..0a18e99 --- /dev/null +++ b/Gopkg.lock @@ -0,0 +1,30 @@ +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + +[[projects]] + name = "github.com/sirupsen/logrus" + packages = ["."] + revision = "c155da19408a8799da419ed3eeb0cb5db0ad5dbc" + version = "v1.0.5" + +[[projects]] + branch = "master" + name = "golang.org/x/crypto" + packages = ["ssh/terminal"] + revision = "beb2a9779c3b677077c41673505f150149fce895" + +[[projects]] + branch = "master" + name = "golang.org/x/sys" + packages = [ + "unix", + "windows" + ] + revision = "3b87a42e500a6dc65dae1a55d0b641295971163e" + +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + inputs-digest = "f0abeb920368b3b2e50d99f6e5705f0ad6ccd5f7e708f639b6c1fa0820364a22" + solver-name = "gps-cdcl" + solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml new file mode 100644 index 0000000..5defd2b --- /dev/null +++ b/Gopkg.toml @@ -0,0 +1,25 @@ +# Gopkg.toml example +# +# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md +# for detailed Gopkg.toml documentation. +# +# required = ["github.com/user/thing/cmd/thing"] +# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] +# +# [[constraint]] +# name = "github.com/user/project" +# version = "1.0.0" +# +# [[constraint]] +# name = "github.com/user/project2" +# branch = "dev" +# source = "github.com/myfork/project2" +# +# [[override]] +# name = "github.com/x/y" +# version = "2.4.0" + + +[[constraint]] + name = "github.com/sirupsen/logrus" + version = "1.0.5" diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..fd6784f --- /dev/null +++ b/Makefile @@ -0,0 +1,27 @@ +all: deps browserpass test + +.PHONY: deps +deps: + dep ensure + +browserpass: *.go + go build -o $@ + +browserpass-linux64: *.go + env GOOS=linux GOARCH=amd64 go build -o $@ + +browserpass-windows64: *.go + env GOOS=windows GOARCH=amd64 go build -o $@.exe + +browserpass-darwinx64: *.go + env GOOS=darwin GOARCH=amd64 go build -o $@ + +browserpass-openbsd64: *.go + env GOOS=openbsd GOARCH=amd64 go build -o $@ + +browserpass-freebsd64: *.go + env GOOS=freebsd GOARCH=amd64 go build -o $@ + +.PHONY: test +test: + go test diff --git a/main.go b/main.go new file mode 100644 index 0000000..0e4e6ea --- /dev/null +++ b/main.go @@ -0,0 +1,32 @@ +package main + +import ( + "flag" + "os" + + log "github.com/sirupsen/logrus" +) + +// VERSION host app version +const VERSION = "3.0.0" + +func main() { + var verbose bool + var version bool + flag.BoolVar(&verbose, "v", false, "print verbose output") + flag.BoolVar(&version, "version", false, "print version and exit") + flag.Parse() + + log.SetFormatter(&log.TextFormatter{FullTimestamp: true}) + if verbose { + log.SetLevel(log.DebugLevel) + } + + if version { + log.Info("Browserpass host app version: ", VERSION) + os.Exit(0) + } + + log.Debugf("Starting browserpass host app v%v", VERSION) + process() +} diff --git a/process.go b/process.go new file mode 100644 index 0000000..5a04935 --- /dev/null +++ b/process.go @@ -0,0 +1,5 @@ +package main + +func process() { + // read stdin, process request, print to stdout... +}