Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ jobs:
uses: actions/cache@v5
with:
path: ~/.cache/golangci-lint
key: ${{ runner.os }}-golangci-lint-${{ hashFiles('**/go.mod') }}
key: golangci-lint-${{ runner.os }}-${{ hashFiles('**/go.mod') }}
restore-keys: |
${{ runner.os }}-golangci-lint-
golangci-lint-${{ runner.os }}--

- name: Run tidy
run: make tidy && git diff --exit-code
Expand Down
7 changes: 5 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ linters:
disable:
# Project specific linters
- containedctx # containedctx is a linter that detects struct contained context.Context field [fast: false, auto-fix: false]
- modernize
# Discouraged linters
- noinlineerr # Disallows inline error handling (`if err := ...; err != nil {`).
- embeddedstructfieldcheck # Embedded types should be at the top of the field list of a struct, and there must be an empty line separating embedded fields from regular fields. [fast]
Expand Down Expand Up @@ -54,26 +53,30 @@ linters:

# https://golangci-lint.run/docs/linters/
settings:
# https://golangci-lint.run/docs/linters/configuration/#exhaustive
exhaustive:
default-signifies-exhaustive: true
# https://golangci-lint.run/docs/linters/configuration/#gocritic
gocritic:
disabled-checks:
- assignOp
- ifElseChain
- deprecatedComment
# https://golangci-lint.run/docs/linters/configuration/#gomoddirectives
gomoddirectives:
replace-local: true
# https://golangci-lint.run/docs/linters/configuration/#gosec
gosec:
severity: medium
confidence: medium
# https://golangci-lint.run/docs/linters/configuration/#revive
revive:
rules:
- name: exported
disabled: true
- name: package-comments
disabled: true
exclusions:
generated: lax
presets:
- comments
- common-false-positives
Expand Down
2 changes: 1 addition & 1 deletion .lefthook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pre-commit:
golangci-lint:
glob: "*.go"
run: golangci-lint run --new --fast-only
stage_fixed: true
stage_fixed: false

commit-msg:
skip: [ merge, rebase ]
Expand Down
4 changes: 2 additions & 2 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tools]
# https://mise-tools.jdx.dev/tools/lefthook
lefthook = "2.1.0"
lefthook = "2.1.1"
# https://mise-tools.jdx.dev/tools/golangci-lint
golangci-lint = "2.9.0"
golangci-lint = "2.10.1"
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ endif

.PHONY: check
## Run lint & tests
check: tidy lint test
check: tidy generate lint test

.PHONY: tidy
## Run go mod tidy
Expand Down Expand Up @@ -75,7 +75,7 @@ test:
## Run go tests with `race` flag
test.race:
@echo "〉go test with -race"
@GO_TEST_TAGS=-skip,race go test -tags=safe -coverprofile=coverage.out -race work
@GO_TEST_TAGS=-skip go test -tags=safe -coverprofile=coverage.out -race work

.PHONY: test.update
## Run go tests with `update` flag
Expand Down
28 changes: 14 additions & 14 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
var (
config *viper.Viper
requiredKeys []string
defaults = map[string]interface{}{}
defaults = map[string]any{}
types = map[string]string{}
)

Expand Down Expand Up @@ -238,18 +238,18 @@ func MustGetStringSlice(c *viper.Viper, key string) func() []string {
}
}

func GetStringMap(c *viper.Viper, key string, fallback map[string]interface{}) func() map[string]interface{} {
func GetStringMap(c *viper.Viper, key string, fallback map[string]any) func() map[string]any {
setDefault(c, key, "map[string]interface{}", fallback)

return func() map[string]interface{} {
return func() map[string]any {
return c.GetStringMap(key)
}
}

func MustGetStringMap(c *viper.Viper, key string) func() map[string]interface{} {
func MustGetStringMap(c *viper.Viper, key string) func() map[string]any {
must(c, key, "map[string]interface{}")

return func() map[string]interface{} {
return func() map[string]any {
return c.GetStringMap(key)
}
}
Expand Down Expand Up @@ -286,17 +286,17 @@ func MustGetStringMapStringSlice(c *viper.Viper, key string) func() map[string][
}
}

func GetStruct(c *viper.Viper, key string, fallback interface{}) (func(v interface{}) error, error) {
func GetStruct(c *viper.Viper, key string, fallback any) (func(v any) error, error) {
c = ensure(c)

// decode default
var decoded map[string]interface{}
var decoded map[string]any
if err := decode(fallback, &decoded); err != nil {
return nil, err
}

// prefix key
configMap := make(map[string]interface{}, len(decoded))
configMap := make(map[string]any, len(decoded))
for s, i := range decoded {
configMap[key+"."+s] = i
}
Expand All @@ -305,15 +305,15 @@ func GetStruct(c *viper.Viper, key string, fallback interface{}) (func(v interfa
return nil, err
}

return func(v interface{}) error {
var cfg map[string]interface{}
return func(v any) error {
var cfg map[string]any
if err := c.Unmarshal(&cfg); err != nil {
return err
}

for _, keyPart := range strings.Split(key, ".") {
for keyPart := range strings.SplitSeq(key, ".") {
if cfgPart, ok := cfg[keyPart]; ok {
if o, ok := cfgPart.(map[string]interface{}); ok {
if o, ok := cfgPart.(map[string]any); ok {
cfg = o
}
}
Expand All @@ -327,7 +327,7 @@ func RequiredKeys() []string {
return requiredKeys
}

func Defaults() map[string]interface{} {
func Defaults() map[string]any {
return defaults
}

Expand Down Expand Up @@ -361,7 +361,7 @@ func must(c *viper.Viper, key, typeof string) {
}
}

func decode(input, output interface{}) error {
func decode(input, output any) error {
decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
TagName: "yaml",
Result: output,
Expand Down
2 changes: 1 addition & 1 deletion config/readme.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func Readme() string {
{
keys := c.AllKeys()
for _, key := range keys {
var fallback interface{}
var fallback any
if v, ok := defaults[key]; ok {
fallback = v
}
Expand Down
10 changes: 5 additions & 5 deletions env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func MustGetGetIntSlice(key string) []int {
func RequiredKeys() []string {
var ret []string

requiredKeys.Range(func(key, value interface{}) bool {
requiredKeys.Range(func(key, value any) bool {
if v, ok := key.(string); ok {
ret = append(ret, v)
}
Expand All @@ -190,10 +190,10 @@ func RequiredKeys() []string {
return ret
}

func Defaults() map[string]interface{} {
ret := map[string]interface{}{}
func Defaults() map[string]any {
ret := map[string]any{}

defaults.Range(func(key, value interface{}) bool {
defaults.Range(func(key, value any) bool {
if k, ok := key.(string); ok {
ret[k] = value
}
Expand All @@ -207,7 +207,7 @@ func Defaults() map[string]interface{} {
func Types() map[string]string {
ret := map[string]string{}

types.Range(func(key, value interface{}) bool {
types.Range(func(key, value any) bool {
if v, ok := value.(string); ok {
if k, ok := key.(string); ok {
ret[k] = v
Expand Down
22 changes: 0 additions & 22 deletions errors/wrappederror.go

This file was deleted.

88 changes: 0 additions & 88 deletions errors/wrappederror_test.go

This file was deleted.

58 changes: 0 additions & 58 deletions examples/errors/main.go

This file was deleted.

Loading