-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: bwplotka <[email protected]>
- Loading branch information
Showing
44 changed files
with
2,539 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
# Ignore everything | ||
* | ||
|
||
# But not these files: | ||
!.gitignore | ||
!*.mod | ||
!README.md | ||
!Variables.mk | ||
!variables.env | ||
|
||
*tmp.mod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Project Development Dependencies. | ||
|
||
This is directory which stores Go modules with pinned buildable package that is used within this repository, managed by https://github.com/bwplotka/bingo. | ||
|
||
* Run `bingo get` to install all tools having each own module file in this directory. | ||
* Run `bingo get <tool>` to install <tool> that have own module file in this directory. | ||
* For Makefile: Make sure to put `include .bingo/Variables.mk` in your Makefile, then use $(<upper case tool name>) variable where <tool> is the .bingo/<tool>.mod. | ||
* For shell: Run `source .bingo/variables.env` to source all environment variable for each tool. | ||
* For go: Import `.bingo/variables.go` to for variable names. | ||
* See https://github.com/bwplotka/bingo or -h on how to add, remove or change binaries dependencies. | ||
|
||
## Requirements | ||
|
||
* Go 1.14+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.4.2. DO NOT EDIT. | ||
# All tools are designed to be build inside $GOBIN. | ||
BINGO_DIR := $(dir $(lastword $(MAKEFILE_LIST))) | ||
GOPATH ?= $(shell go env GOPATH) | ||
GOBIN ?= $(firstword $(subst :, ,${GOPATH}))/bin | ||
GO ?= $(shell which go) | ||
|
||
# Below generated variables ensure that every time a tool under each variable is invoked, the correct version | ||
# will be used; reinstalling only if needed. | ||
# For example for bingo variable: | ||
# | ||
# In your main Makefile (for non array binaries): | ||
# | ||
#include .bingo/Variables.mk # Assuming -dir was set to .bingo . | ||
# | ||
#command: $(BINGO) | ||
# @echo "Running bingo" | ||
# @$(BINGO) <flags/args..> | ||
# | ||
BINGO := $(GOBIN)/bingo-v0.2.4-0.20201227120526-df6eae8f6734 | ||
$(BINGO): $(BINGO_DIR)/bingo.mod | ||
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. | ||
@echo "(re)installing $(GOBIN)/bingo-v0.2.4-0.20201227120526-df6eae8f6734" | ||
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=bingo.mod -o=$(GOBIN)/bingo-v0.2.4-0.20201227120526-df6eae8f6734 "github.com/bwplotka/bingo" | ||
|
||
FAILLINT := $(GOBIN)/faillint-v1.5.0 | ||
$(FAILLINT): $(BINGO_DIR)/faillint.mod | ||
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. | ||
@echo "(re)installing $(GOBIN)/faillint-v1.5.0" | ||
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=faillint.mod -o=$(GOBIN)/faillint-v1.5.0 "github.com/fatih/faillint" | ||
|
||
GOIMPORTS := $(GOBIN)/goimports-v0.0.0-20200519204825-e64124511800 | ||
$(GOIMPORTS): $(BINGO_DIR)/goimports.mod | ||
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. | ||
@echo "(re)installing $(GOBIN)/goimports-v0.0.0-20200519204825-e64124511800" | ||
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=goimports.mod -o=$(GOBIN)/goimports-v0.0.0-20200519204825-e64124511800 "golang.org/x/tools/cmd/goimports" | ||
|
||
GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.26.0 | ||
$(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.mod | ||
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. | ||
@echo "(re)installing $(GOBIN)/golangci-lint-v1.26.0" | ||
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.26.0 "github.com/golangci/golangci-lint/cmd/golangci-lint" | ||
|
||
MDOX := $(GOBIN)/mdox-v0.2.2-0.20210731105602-946757ef5f98 | ||
$(MDOX): $(BINGO_DIR)/mdox.mod | ||
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. | ||
@echo "(re)installing $(GOBIN)/mdox-v0.2.2-0.20210731105602-946757ef5f98" | ||
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=mdox.mod -o=$(GOBIN)/mdox-v0.2.2-0.20210731105602-946757ef5f98 "github.com/bwplotka/mdox" | ||
|
||
MISSPELL := $(GOBIN)/misspell-v0.3.4 | ||
$(MISSPELL): $(BINGO_DIR)/misspell.mod | ||
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. | ||
@echo "(re)installing $(GOBIN)/misspell-v0.3.4" | ||
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=misspell.mod -o=$(GOBIN)/misspell-v0.3.4 "github.com/client9/misspell/cmd/misspell" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT | ||
|
||
go 1.15 | ||
|
||
require github.com/bwplotka/bingo v0.2.4-0.20201227120526-df6eae8f6734 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT | ||
|
||
go 1.14 | ||
|
||
require github.com/fatih/faillint v1.5.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module _ // Fake go.mod auto-created by 'bingo' for go -moddir compatibility with non-Go projects. Commit this file, together with other .mod files. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT | ||
|
||
go 1.14 | ||
|
||
require golang.org/x/tools v0.0.0-20200519204825-e64124511800 // cmd/goimports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT | ||
|
||
go 1.14 | ||
|
||
require github.com/golangci/golangci-lint v1.26.0 // cmd/golangci-lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT | ||
|
||
go 1.15 | ||
|
||
require github.com/bwplotka/mdox v0.2.2-0.20210731105602-946757ef5f98 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT | ||
|
||
go 1.14 | ||
|
||
require github.com/client9/misspell v0.3.4 // cmd/misspell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.4.2. DO NOT EDIT. | ||
# All tools are designed to be build inside $GOBIN. | ||
# Those variables will work only until 'bingo get' was invoked, or if tools were installed via Makefile's Variables.mk. | ||
GOBIN=${GOBIN:=$(go env GOBIN)} | ||
|
||
if [ -z "$GOBIN" ]; then | ||
GOBIN="$(go env GOPATH)/bin" | ||
fi | ||
|
||
|
||
BINGO="${GOBIN}/bingo-v0.2.4-0.20201227120526-df6eae8f6734" | ||
|
||
FAILLINT="${GOBIN}/faillint-v1.5.0" | ||
|
||
GOIMPORTS="${GOBIN}/goimports-v0.0.0-20200519204825-e64124511800" | ||
|
||
GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.26.0" | ||
|
||
MDOX="${GOBIN}/mdox-v0.2.2-0.20210731105602-946757ef5f98" | ||
|
||
MISSPELL="${GOBIN}/misspell-v0.3.4" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(github.com/go-kit/kit/log.Logger).Log | ||
fmt.Fprintln | ||
fmt.Fprint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: go | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
pull_request: | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
name: Linters (Static Analysis) for Go | ||
steps: | ||
- name: Checkout code into the Go module directory. | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.15.x | ||
|
||
- uses: actions/cache@v1 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
|
||
- name: Linting & vetting. | ||
env: | ||
GOBIN: /tmp/.bin | ||
run: make lint | ||
tests: | ||
runs-on: ${{ matrix.platform }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
go: [ '1.14.x', '1.15.x'] | ||
platform: [ubuntu-latest, macos-latest] | ||
|
||
name: Unit tests on Go ${{ matrix.go }} ${{ matrix.platform }} | ||
steps: | ||
- name: Checkout code into the Go module directory. | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
|
||
- uses: actions/cache@v1 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
|
||
- name: Run unit tests. | ||
env: | ||
GOBIN: /tmp/.bin | ||
run: make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,6 @@ | |
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
.bin | ||
.envrc | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Copyright (c) The EfficientGo Authors. | ||
Licensed under the Apache License 2.0. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
include .bingo/Variables.mk | ||
|
||
MODULES ?= $(shell find $(PWD) -name "go.mod" | grep -v ".bingo" | xargs dirname) | ||
|
||
GO111MODULE ?= on | ||
export GO111MODULE | ||
|
||
GOBIN ?= $(firstword $(subst :, ,${GOPATH}))/bin | ||
|
||
# Tools. | ||
GIT ?= $(shell which git) | ||
|
||
# Support gsed on OSX (installed via brew), falling back to sed. On Linux | ||
# systems gsed won't be installed, so will use sed as expected. | ||
SED ?= $(shell which gsed 2>/dev/null || which sed) | ||
|
||
define require_clean_work_tree | ||
@git update-index -q --ignore-submodules --refresh | ||
|
||
@if ! git diff-files --quiet --ignore-submodules --; then \ | ||
echo >&2 "$1: you have unstaged changes."; \ | ||
git diff-files --name-status -r --ignore-submodules -- >&2; \ | ||
echo >&2 "Please commit or stash them."; \ | ||
exit 1; \ | ||
fi | ||
|
||
@if ! git diff-index --cached --quiet HEAD --ignore-submodules --; then \ | ||
echo >&2 "$1: your index contains uncommitted changes."; \ | ||
git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2; \ | ||
echo >&2 "Please commit or stash them."; \ | ||
exit 1; \ | ||
fi | ||
|
||
endef | ||
|
||
help: ## Displays help. | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST) | ||
|
||
.PHONY: all | ||
all: format build | ||
|
||
.PHONY: build | ||
build: ## Build all modules | ||
@echo ">> building all modules: $(MODULES)" | ||
for dir in $(MODULES) ; do \ | ||
echo ">> building in $${dir}"; \ | ||
cd $${dir} && go test -run=nope ./...; \ | ||
done | ||
@echo ">> building copyright" | ||
@cd copyright && go build -o $(GOBIN)/copyright . | ||
|
||
.PHONY: deps | ||
deps: ## Cleans up deps for all modules | ||
@echo ">> running deps tidy for all modules: $(MODULES)" | ||
for dir in $(MODULES) ; do \ | ||
cd $${dir} && go mod tidy; \ | ||
done | ||
|
||
.PHONY: docs | ||
docs: $(MDOX) ## Generates config snippets and doc formatting. | ||
@echo ">> generating docs $(PATH)" | ||
@$(MDOX) fmt -l *.md | ||
|
||
.PHONY: format | ||
format: ## Formats Go code. | ||
format: $(GOIMPORTS) | ||
@echo ">> formatting all modules Go code: $(MODULES)" | ||
@$(GOIMPORTS) -w $(MODULES) | ||
|
||
.PHONY: test | ||
test: ## Runs all Go unit tests. | ||
@echo ">> running tests for all modules: $(MODULES)" | ||
for dir in $(MODULES) ; do \ | ||
cd $${dir} && go test -v -race ./...; \ | ||
done | ||
|
||
.PHONY: check-git | ||
check-git: | ||
ifneq ($(GIT),) | ||
@test -x $(GIT) || (echo >&2 "No git executable binary found at $(GIT)."; exit 1) | ||
else | ||
@echo >&2 "No git binary found."; exit 1 | ||
endif | ||
|
||
# PROTIP: | ||
# Add | ||
# --cpu-profile-path string Path to CPU profile output file | ||
# --mem-profile-path string Path to memory profile output file | ||
# to debug big allocations during linting. | ||
lint: ## Runs various static analysis against our code. | ||
lint: $(FAILLINT) $(GOLANGCI_LINT) $(MISSPELL) build format docs check-git deps | ||
$(call require_clean_work_tree,"detected not clean master before running lint - run make lint and commit changes.") | ||
@echo ">> verifying imported " | ||
for dir in $(MODULES) ; do \ | ||
cd $${dir} && $(FAILLINT) -paths "fmt.{Print,PrintfPrintln,Sprint}" -ignore-tests ./... && \ | ||
$(FAILLINT) -paths "github.com/stretchr/testify=github.com/efficientgo/tools/core/pkg/testutil" ./...; \ | ||
done | ||
@echo ">> examining all of the Go files" | ||
for dir in $(MODULES) ; do \ | ||
cd $${dir} && go vet -stdmethods=false ./...; \ | ||
done | ||
@echo ">> linting all of the Go files GOGC=${GOGC}" | ||
for dir in $(MODULES) ; do \ | ||
cd $${dir} && $(GOLANGCI_LINT) run; \ | ||
done | ||
@echo ">> detecting misspells" | ||
@find . -type f | grep -v vendor/ | grep -vE '\./\..*' | xargs $(MISSPELL) -error | ||
@echo ">> ensuring Copyright headers" | ||
@$(GOBIN)/copyright $(shell go list -f "{{.Dir}}" ./... | xargs -i find "{}" -name "*.go") | ||
$(call require_clean_work_tree,"detected files without copyright - run make lint and commit changes.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,16 @@ | ||
# core | ||
Set of core packages every Go project needs. Minimal API, strictly versioned and with no transient dependencies. | ||
|
||
[![core module docs](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/github.com/efficientgo/core) | ||
|
||
Go module with set of core packages *every* Go project needs. Minimal API, battle-tested, strictly versioned and with no transient dependencies. | ||
|
||
Maintained by experienced Go developers, including author of the https://www.oreilly.com/library/view/efficient-go/9781098105709/[Efficient Go] book. | ||
|
||
## Packages | ||
|
||
* `pkg/clilog`: | ||
* `pkg/errcapture` | ||
* `pkg/logerrcapture` | ||
* `pkg/merrors` | ||
* `pkg/runutil` | ||
* `pkg/testutil` |
Oops, something went wrong.