Skip to content

Commit 5263d38

Browse files
committed
feat: initial commit
0 parents  commit 5263d38

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2199
-0
lines changed

.editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 2
7+
indent_style = tab
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.{yaml,yml,md,mdx}]
12+
indent_style = space

.github/dependabot.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
version: 2
2+
3+
updates:
4+
- package-ecosystem: 'github-actions'
5+
directory: '/'
6+
schedule:
7+
day: 'sunday'
8+
interval: 'weekly'
9+
groups:
10+
github-actions:
11+
patterns:
12+
- '*'
13+
14+
- package-ecosystem: 'gomod'
15+
directory: '/'
16+
schedule:
17+
day: 'sunday'
18+
interval: 'weekly'
19+
groups:
20+
gomod-security:
21+
applies-to: security-updates
22+
patterns: ['*']
23+
gomod-update:
24+
applies-to: version-updates
25+
patterns: ['*']

.github/workflows/release.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release Tag
2+
3+
on:
4+
push:
5+
tags:
6+
- v*.*.*
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- uses: actions/setup-go@v5
21+
with:
22+
check-latest: true
23+
go-version-file: go.mod
24+
25+
- id: app_token
26+
uses: tibdex/github-app-token@v2
27+
with:
28+
app_id: ${{ secrets.TOKEN_APP_ID }}
29+
private_key: ${{ secrets.TOKEN_APP_PRIVATE_KEY }}
30+
31+
- uses: goreleaser/goreleaser-action@v6
32+
with:
33+
version: latest
34+
args: release --clean
35+
env:
36+
GITHUB_TOKEN: ${{ steps.app_token.outputs.token }}

.github/workflows/test.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Test Branch
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
merge_group:
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}"
12+
cancel-in-progress: true
13+
14+
jobs:
15+
test:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- uses: actions/setup-go@v5
21+
with:
22+
check-latest: true
23+
go-version-file: 'go.mod'
24+
25+
- uses: gotesttools/gotestfmt-action@v2
26+
with:
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- uses: golangci/golangci-lint-action@v6
30+
with:
31+
version: latest
32+
33+
- name: Run tests
34+
run: make test
35+
36+
- uses: coverallsapp/github-action@v2
37+
with:
38+
file: coverage.out

.gitignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.*
2+
*.zip
3+
*.tar
4+
*.out
5+
*.log
6+
/bin/
7+
/tmp/
8+
9+
## Git
10+
!.gitkeep
11+
!.gitignore
12+
13+
## GitHub
14+
!.github/
15+
16+
## Editorconfig
17+
!.editorconfig
18+
19+
## Husky
20+
!.husky/
21+
!.husky.yaml
22+
23+
## Golang
24+
!.golangci.yml
25+
!.goreleaser.yml

.golangci.yml

+193
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
issues:
2+
exclude-dirs:
3+
- 'bin'
4+
- 'tmp'
5+
exclude-rules:
6+
- path: _test\.go
7+
linters:
8+
- forcetypeassert
9+
10+
linters-settings:
11+
# https://golangci-lint.run/usage/linters/#misspell
12+
misspell:
13+
mode: restricted
14+
# https://golangci-lint.run/usage/linters/#asasalint
15+
asasalint:
16+
ignore-test: true
17+
# https://golangci-lint.run/usage/linters/#exhaustive
18+
exhaustive:
19+
default-signifies-exhaustive: true
20+
# https://golangci-lint.run/usage/linters/#predeclared
21+
predeclared:
22+
ignore: "new,error"
23+
# https://golangci-lint.run/usage/linters/#gocritic
24+
gocritic:
25+
disabled-checks:
26+
- ifElseChain
27+
- commentFormatting
28+
# https://golangci-lint.run/usage/linters/#testifylint
29+
testifylint:
30+
disable:
31+
- float-compare
32+
# https://golangci-lint.run/usage/linters/#gosec
33+
gosec:
34+
confidence: medium
35+
excludes:
36+
- G204
37+
# https://golangci-lint.run/usage/linters/#importas
38+
importas:
39+
no-unaliased: true
40+
# https://golangci-lint.run/usage/linters/#gomoddirectives
41+
gomoddirectives:
42+
replace-local: true
43+
# https://golangci-lint.run/usage/linters/#revive
44+
revive:
45+
ignore-generated-header: true
46+
enable-all-rules: true
47+
rules:
48+
- name: line-length-limit
49+
disabled: true
50+
- name: cognitive-complexity
51+
disabled: true
52+
- name: unused-parameter
53+
disabled: true
54+
- name: add-constant
55+
disabled: true
56+
- name: cyclomatic
57+
disabled: true
58+
- name: function-length
59+
disabled: true
60+
- name: function-result-limit
61+
disabled: true
62+
- name: flag-parameter
63+
disabled: true
64+
- name: unused-receiver
65+
disabled: true
66+
- name: argument-limit
67+
disabled: true
68+
- name: max-control-nesting
69+
disabled: true
70+
- name: comment-spacings
71+
disabled: true
72+
- name: struct-tag
73+
arguments:
74+
- "json,inline"
75+
- "yaml,squash"
76+
- name: unhandled-error
77+
arguments:
78+
- "fmt.Println"
79+
- "viper.BindPFlag"
80+
- "strings.Builder.WriteString"
81+
82+
linters:
83+
disable-all: true
84+
enable:
85+
## Enabled by default linters:
86+
- errcheck # errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases [fast: false, auto-fix: false]
87+
- gosimple # (megacheck) Linter for Go source code that specializes in simplifying code [fast: false, auto-fix: false]
88+
- govet # (vet, vetshadow) Vet examines Go source code and reports suspicious constructs. It is roughly the same as 'go vet' and uses its passes. [fast: false, auto-fix: false]
89+
- ineffassign # Detects when assignments to existing variables are not used [fast: true, auto-fix: false]
90+
- staticcheck # (megacheck) It's a set of rules from staticcheck. It's not the same thing as the staticcheck binary. The author of staticcheck doesn't support or approve the use of staticcheck as a library inside golangci-lint. [fast: false, auto-fix: false]
91+
- unused # (megacheck) Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false]
92+
93+
## Disabled by your configuration linters:
94+
- asasalint # check for pass []any as any in variadic func(...any) [fast: false, auto-fix: false]
95+
- asciicheck # checks that all code identifiers does not have non-ASCII symbols in the name [fast: true, auto-fix: false]
96+
- bidichk # Checks for dangerous unicode character sequences [fast: true, auto-fix: false]
97+
- bodyclose # checks whether HTTP response body is closed successfully [fast: false, auto-fix: false]
98+
- containedctx # containedctx is a linter that detects struct contained context.Context field [fast: false, auto-fix: false]
99+
- contextcheck # check whether the function uses a non-inherited context [fast: false, auto-fix: false]
100+
- copyloopvar # (go >= 1.22) copyloopvar is a linter detects places where loop variables are copied [fast: true, auto-fix: false]
101+
- decorder # check declaration order and count of types, constants, variables and functions [fast: true, auto-fix: false]
102+
- durationcheck # check for two durations multiplied together [fast: false, auto-fix: false]
103+
- errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and reports occations, where the check for the returned error can be omitted. [fast: false, auto-fix: false]
104+
- errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`. [fast: false, auto-fix: false]
105+
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13. [fast: false, auto-fix: false]
106+
- exhaustive # check exhaustiveness of enum switch statements [fast: false, auto-fix: false]
107+
#- forbidigo # Forbids identifiers [fast: false, auto-fix: false]
108+
- forcetypeassert # finds forced type assertions [fast: true, auto-fix: false]
109+
- gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid. [fast: true, auto-fix: false]
110+
- gochecksumtype # Run exhaustiveness checks on Go "sum types" [fast: false, auto-fix: false]
111+
- goconst # Finds repeated strings that could be replaced by a constant [fast: true, auto-fix: false]
112+
- gocritic # Provides diagnostics that check for bugs, performance and style issues. [fast: false, auto-fix: true]
113+
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification [fast: true, auto-fix: true]
114+
- goheader # Checks is file header matches to pattern [fast: true, auto-fix: true]
115+
- goimports # Check import statements are formatted according to the 'goimport' command. Reformat imports in autofix mode. [fast: true, auto-fix: true]
116+
- gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. [fast: true, auto-fix: false]
117+
- gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations. [fast: true, auto-fix: false]
118+
- goprintffuncname # Checks that printf-like functions are named with `f` at the end. [fast: true, auto-fix: false]
119+
- gosec # (gas) Inspects source code for security problems [fast: false, auto-fix: false]
120+
- gosmopolitan # Report certain i18n/l10n anti-patterns in your Go codebase [fast: false, auto-fix: false]
121+
- grouper # Analyze expression groups. [fast: true, auto-fix: false]
122+
- importas # Enforces consistent import aliases [fast: false, auto-fix: false]
123+
- inamedparam # reports interfaces with unnamed method parameters [fast: true, auto-fix: false]
124+
- intrange # (go >= 1.22) intrange is a linter to find places where for loops could make use of an integer range. [fast: true, auto-fix: false]
125+
- loggercheck # (logrlint) Checks key value pairs for common logger libraries (kitlog,klog,logr,zap). [fast: false, auto-fix: false]
126+
- makezero # Finds slice declarations with non-zero initial length [fast: false, auto-fix: false]
127+
- misspell # Finds commonly misspelled English words [fast: true, auto-fix: true]
128+
- mirror # reports wrong mirror patterns of bytes/strings usage [fast: false, auto-fix: true]
129+
- musttag # enforce field tags in (un)marshaled structs [fast: false, auto-fix: false]
130+
- nakedret # Checks that functions with naked returns are not longer than a maximum size (can be zero). [fast: true, auto-fix: false]
131+
- nilerr # Finds the code that returns nil even if it checks that the error is not nil. [fast: false, auto-fix: false]
132+
- nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value. [fast: false, auto-fix: false]
133+
- noctx # Finds sending http request without context.Context [fast: false, auto-fix: false]
134+
- nolintlint # Reports ill-formed or insufficient nolint directives [fast: true, auto-fix: true]
135+
- nonamedreturns # Reports all named returns [fast: false, auto-fix: false]
136+
- nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. [fast: true, auto-fix: false]
137+
- paralleltest # Detects missing usage of t.Parallel() method in your Go test [fast: false, auto-fix: false]
138+
- predeclared # find code that shadows one of Go's predeclared identifiers [fast: true, auto-fix: false]
139+
- promlinter # Check Prometheus metrics naming via promlint [fast: true, auto-fix: false]
140+
- reassign # Checks that package variables are not reassigned [fast: false, auto-fix: false]
141+
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. [fast: false, auto-fix: false]
142+
- rowserrcheck # checks whether Rows.Err of rows is checked successfully [fast: false, auto-fix: false]
143+
- spancheck # Checks for mistakes with OpenTelemetry/Census spans. [fast: false, auto-fix: false]
144+
- sqlclosecheck # Checks that sql.Rows, sql.Stmt, sqlx.NamedStmt, pgx.Query are closed. [fast: false, auto-fix: false]
145+
- stylecheck # Stylecheck is a replacement for golint [fast: false, auto-fix: false]
146+
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17 [fast: false, auto-fix: false]
147+
- testableexamples # linter checks if examples are testable (have an expected output) [fast: true, auto-fix: false]
148+
- testifylint # Checks usage of github.com/stretchr/testify. [fast: false, auto-fix: false]
149+
- testpackage # linter that makes you use a separate _test package [fast: true, auto-fix: false]
150+
- thelper # thelper detects tests helpers which is not start with t.Helper() method. [fast: false, auto-fix: false]
151+
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes. [fast: false, auto-fix: false]
152+
- unconvert # Remove unnecessary type conversions [fast: false, auto-fix: false]
153+
- usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. [fast: true, auto-fix: false]
154+
- wastedassign # Finds wasted assignment statements [fast: false, auto-fix: false]
155+
- whitespace # Whitespace is a linter that checks for unnecessary newlines at the start and end of functions, if, for, etc. [fast: true, auto-fix: true]
156+
- canonicalheader # Checks whether net/http.Header uses canonical header [fast: false, auto-fix: false]
157+
- fatcontext #Detects nested contexts in loops [fast: false, auto-fix: false]
158+
159+
## Don't enable
160+
#- cyclop # checks function and package cyclomatic complexity [fast: false, auto-fix: false]
161+
#- depguard # Go linter that checks if package imports are in a list of acceptable packages [fast: true, auto-fix: false]
162+
#- dupl # Tool for code clone detection [fast: true, auto-fix: false]
163+
#- dupword # checks for duplicate words in the source code [fast: true, auto-fix: false]
164+
#- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) [fast: true, auto-fix: false]
165+
#- err113 # Go linter to check the errors handling expressions [fast: false, auto-fix: false]
166+
#- exhaustruct # Checks if all structure fields are initialized [fast: false, auto-fix: false]
167+
#- gci # Gci controls Go package import order and makes it always deterministic. [fast: true, auto-fix: true]
168+
#- gochecknoglobals # Check that no global variables exist. [fast: false, auto-fix: false]
169+
#- gochecknoinits # Checks that no init functions are present in Go code [fast: true, auto-fix: false]
170+
#- gocyclo # Computes and checks the cyclomatic complexity of functions [fast: true, auto-fix: false]
171+
#- godot # Check if comments end in a period [fast: true, auto-fix: true]
172+
#- godox # Tool for detection of FIXME, TODO and other comment keywords [fast: true, auto-fix: false]
173+
#- gofumpt # Gofumpt checks whether code was gofumpt-ed. [fast: true, auto-fix: true]
174+
#- funlen # Tool for detection of long functions [fast: true, auto-fix: false]
175+
#- ginkgolinter # enforces standards of using ginkgo and gomega [fast: false, auto-fix: false]
176+
#- gocognit # Computes and checks the cognitive complexity of functions [fast: true, auto-fix: false]
177+
#- interfacebloat # A linter that checks the number of methods inside an interface. [fast: true, auto-fix: false]
178+
#- lll # Reports long lines [fast: true, auto-fix: false]
179+
#- ireturn # Accept Interfaces, Return Concrete Types [fast: false, auto-fix: false]
180+
#- maintidx # maintidx measures the maintainability index of each function. [fast: true, auto-fix: false]
181+
#- nestif # Reports deeply nested if statements [fast: true, auto-fix: false]
182+
#- nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity [fast: true, auto-fix: false]
183+
#- perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. [fast: false, auto-fix: false]
184+
#- prealloc # Finds slice declarations that could potentially be pre-allocated [fast: true, auto-fix: false]
185+
#- protogetter # Reports direct reads from proto message fields when getters should be used [fast: false, auto-fix: true]
186+
#- sloglint # ensure consistent code style when using log/slog [fast: false, auto-fix: false]
187+
#- tagalign # check that struct tags are well aligned [fast: true, auto-fix: true]
188+
#- tagliatelle # Checks the struct tags. [fast: true, auto-fix: false]
189+
#- unparam # Reports unused function parameters [fast: false, auto-fix: false]
190+
#- varnamelen # checks that the length of a variable's name matches its scope [fast: false, auto-fix: false]
191+
#- wrapcheck # Checks that errors returned from external packages are wrapped [fast: false, auto-fix: false]
192+
#- wsl # add or remove empty lines [fast: true, auto-fix: false]
193+
#- zerologlint # Detects the wrong usage of `zerolog` that a user forgets to dispatch with `Send` or `Msg` [fast: false, auto-fix: false]

.goreleaser.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
version: 2
2+
3+
builds:
4+
- binary: ownbrew
5+
main: ./main.go
6+
env:
7+
- CGO_ENABLED=0
8+
goos:
9+
- windows
10+
- darwin
11+
- linux
12+
goarch:
13+
- amd64
14+
- arm64
15+
goarm:
16+
- '7'
17+
flags:
18+
- -trimpath
19+
ldflags:
20+
- -s -w -X github.com/foomo/ownbrew/cmd.version={{.Version}}
21+
22+
release:
23+
prerelease: auto
24+
25+
archives:
26+
- format: tar.gz
27+
format_overrides:
28+
- goos: windows
29+
format: zip
30+
31+
changelog:
32+
use: github-native
33+
34+
brews:
35+
- repository:
36+
owner: foomo
37+
name: homebrew-tap
38+
caveats: "ownbrew --help"
39+
homepage: "https://github.com/foomo/ownbrew"
40+
description: "Your local project package manager"

.husky.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
hooks:
2+
pre-commit:
3+
- golangci-lint run --fast
4+
- husky lint-staged
5+
commit-msg:
6+
# only execute if not in a merge
7+
- if [[ -z $(git rev-parse -q --verify MERGE_HEAD) ]]; then husky lint-commit; fi
8+
9+
lint-staged:
10+
'*.go':
11+
- goimports -l -w
12+
13+
lint-commit:
14+
types: '^(feat|fix|build|chore|docs|perf|refactor|revert|style|test|wip)$'
15+
header: '^(?P<type>\w+)(\((?P<scope>[\w/.-]+)\))?(?P<breaking>!)?:( +)?(?P<header>.+)'

.husky/applypatch-msg

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
husky hook $(basename "$0") $*

.husky/commit-msg

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
husky hook $(basename "$0") $*

0 commit comments

Comments
 (0)