Fix “should not use basic type string as key in context.WithValue” golint

Just use a key type:

type key int

const (
    keyPrincipalID key = iota
    // ...
)

Since you’ve defined a separate type, it will never collide. Even if you have two packages, pkg1.key(0) != pkg2.key(0).

See also: Go Blog about key collisions in context.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)