[#1459] .golanci.yml: Add tenv linter, fix issues
All checks were successful
Tests and linters / Run gofumpt (pull_request) Successful in 1m26s
DCO action / DCO (pull_request) Successful in 1m38s
Vulncheck / Vulncheck (pull_request) Successful in 2m11s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m56s
Build / Build Components (pull_request) Successful in 3m1s
Tests and linters / Staticcheck (pull_request) Successful in 3m11s
Tests and linters / gopls check (pull_request) Successful in 3m9s
Tests and linters / Lint (pull_request) Successful in 4m13s
Tests and linters / Tests (pull_request) Successful in 7m25s
Tests and linters / Tests with -race (pull_request) Successful in 7m25s

Refs #1309

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2024-10-30 15:33:10 +03:00
parent 9cf5755aa0
commit ab1a9b177c
Signed by: fyrchik
SSH key fingerprint: SHA256:m/TTwCzjnRkXgnzEx9X92ccxy1CcVeinOgDb3NPWWmg
2 changed files with 2 additions and 13 deletions

View file

@ -88,5 +88,6 @@ linters:
- testifylint - testifylint
- protogetter - protogetter
- intrange - intrange
- tenv
disable-all: true disable-all: true
fast: false fast: false

View file

@ -11,8 +11,6 @@ import (
) )
func fromFile(path string) *config.Config { func fromFile(path string) *config.Config {
os.Clearenv() // ENVs have priority over config files, so we do this in tests
return config.New(path, "", "") return config.New(path, "", "")
} }
@ -40,15 +38,6 @@ func ForEachFileType(pref string, f func(*config.Config)) {
// ForEnvFileType creates config from `<pref>.env` file. // ForEnvFileType creates config from `<pref>.env` file.
func ForEnvFileType(t testing.TB, pref string, f func(*config.Config)) { func ForEnvFileType(t testing.TB, pref string, f func(*config.Config)) {
envs := os.Environ()
t.Cleanup(func() {
os.Clearenv()
for _, env := range envs {
keyValue := strings.Split(env, "=")
os.Setenv(keyValue[0], keyValue[1])
}
})
f(fromEnvFile(t, pref+".env")) f(fromEnvFile(t, pref+".env"))
} }
@ -73,7 +62,6 @@ func loadEnv(t testing.TB, path string) {
v = strings.Trim(v, `"`) v = strings.Trim(v, `"`)
err = os.Setenv(k, v) t.Setenv(k, v)
require.NoError(t, err, "can't set environment variable")
} }
} }