Skip to content

Commit

Permalink
chore(linter): update golang-ci config (zurvan-lab#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
kehiy committed Nov 12, 2023
1 parent 558cd25 commit c96db98
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ linters:
- nonamedreturns
- nlreturn
- ireturn
- gofumpt
- tagalign
- funlen
- errname
- errorlint
- forcetypeassert


linters-settings:
Expand Down
12 changes: 6 additions & 6 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
var configBytes []byte

var (
InvalidUserLength = errors.New("invalid user length")
CommandAtSameTime = errors.New("can't have all cmds and specific cmd at same time")
ErrInvalidUserLength = errors.New("invalid user length")
ErrSpecificAndAllCommandSameAtTime = errors.New("can't have all cmds and specific cmd at same time")
)

type Config struct {
Expand Down Expand Up @@ -42,7 +42,7 @@ type User struct {

func (conf *Config) BasicCheck() error {
if len(conf.Users) == 0 {
return InvalidUserLength
return ErrInvalidUserLength
}

for _, u := range conf.Users {
Expand All @@ -55,7 +55,7 @@ func (conf *Config) BasicCheck() error {
}

if allCmds && len(u.Cmds) > 1 {
return CommandAtSameTime
return ErrSpecificAndAllCommandSameAtTime
}
}

Expand All @@ -72,9 +72,9 @@ func DefaultConfig() *Config {
WriteToFile: true,
Path: "log.ttrace",
},
Name: "time_trace",
Name: "time_trace",
}

rootUser := User{
Name: "root",
Password: "super_secret_password",
Expand Down
4 changes: 2 additions & 2 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ func TestBasicCheck(t *testing.T) {

c.Users = []User{}
err = c.BasicCheck()
assert.Error(t, InvalidUserLength, err)
assert.Error(t, ErrInvalidUserLength, err)

c.Users = []User{DefaultConfig().Users[0]}
c.Users[0].Cmds = []string{"*", "GET"}
err = c.BasicCheck()
assert.Error(t, CommandAtSameTime, err)
assert.Error(t, ErrSpecificAndAllCommandSameAtTime, err)
}

0 comments on commit c96db98

Please sign in to comment.