Skip to content

Commit

Permalink
Return value, not a pointer (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
VojtechVitek authored Oct 24, 2024
1 parent fe8f8fe commit 97f2559
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ type UserStore interface {
type Config[T any] map[string]map[string]T

// Get returns the config value for the given request.
func (c Config[T]) Get(path string) (*T, error) {
func (c Config[T]) Get(path string) (v T, err error) {
if c == nil {
return nil, fmt.Errorf("cofig is nil")
return v, fmt.Errorf("cofig is nil")
}

p := strings.Split(path, "/")
if len(p) < 4 {
return nil, fmt.Errorf("path has not enough parts")
return v, fmt.Errorf("path has not enough parts")
}

var (
Expand All @@ -54,15 +54,15 @@ func (c Config[T]) Get(path string) (*T, error) {
)

if packageName != "rpc" {
return nil, fmt.Errorf("path doesn't include rpc")
return v, fmt.Errorf("path doesn't include rpc")
}

methodCfg, ok := c[serviceName][methodName]
v, ok := c[serviceName][methodName]
if !ok {
return nil, fmt.Errorf("acl not found")
return v, fmt.Errorf("acl not found")
}

return &methodCfg, nil
return v, nil
}

// VerifyACL checks that the given ACL config is valid for the given service.
Expand Down

0 comments on commit 97f2559

Please sign in to comment.