refactor: any (#4133)

* refactor: any

* refactor: fix test
pull/4129/head
James Elliott 2022-10-05 16:05:23 +11:00 committed by GitHub
parent 9ae703fe51
commit dc79c8ea59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 73 additions and 73 deletions

View File

@ -79,7 +79,7 @@ func docsDateRunE(cmd *cobra.Command, args []string) (err error) {
return nil return nil
} }
frontmatter := map[string]interface{}{} frontmatter := map[string]any{}
if err = yaml.Unmarshal(frontmatterBytes, frontmatter); err != nil { if err = yaml.Unmarshal(frontmatterBytes, frontmatter); err != nil {
return err return err

View File

@ -168,8 +168,8 @@ func pnpmInstall() {
shell(fmt.Sprintf("cd %s/web && pnpm install", cwd)) shell(fmt.Sprintf("cd %s/web && pnpm install", cwd))
} }
func bootstrapPrintln(args ...interface{}) { func bootstrapPrintln(args ...any) {
a := make([]interface{}, 0) a := make([]any, 0)
a = append(a, "[BOOTSTRAP]") a = append(a, "[BOOTSTRAP]")
a = append(a, args...) a = append(a, args...)
fmt.Println(a...) fmt.Println(a...)

View File

@ -20,10 +20,10 @@ type DockerImages []DockerImage
// DockerImage represents some of the data from the docker images API. // DockerImage represents some of the data from the docker images API.
type DockerImage struct { type DockerImage struct {
Architecture string `json:"architecture"` Architecture string `json:"architecture"`
Variant interface{} `json:"variant"` Variant any `json:"variant"`
Digest string `json:"digest"` Digest string `json:"digest"`
OS string `json:"os"` OS string `json:"os"`
} }
// Match returns true if this image matches the platform. // Match returns true if this image matches the platform.

View File

@ -140,7 +140,7 @@ func NewExtendedSearchRequestMatcher(filter, base string, scope, derefAliases in
return &ExtendedSearchRequestMatcher{filter, base, scope, derefAliases, typesOnly, attributes} return &ExtendedSearchRequestMatcher{filter, base, scope, derefAliases, typesOnly, attributes}
} }
func (e *ExtendedSearchRequestMatcher) Matches(x interface{}) bool { func (e *ExtendedSearchRequestMatcher) Matches(x any) bool {
sr := x.(*ldap.SearchRequest) sr := x.(*ldap.SearchRequest)
if e.filter != sr.Filter || e.baseDN != sr.BaseDN || e.scope != sr.Scope || e.derefAliases != sr.DerefAliases || if e.filter != sr.Filter || e.baseDN != sr.BaseDN || e.scope != sr.Scope || e.derefAliases != sr.DerefAliases ||
@ -502,7 +502,7 @@ func NewSearchRequestMatcher(expected string) *SearchRequestMatcher {
return &SearchRequestMatcher{expected} return &SearchRequestMatcher{expected}
} }
func (srm *SearchRequestMatcher) Matches(x interface{}) bool { func (srm *SearchRequestMatcher) Matches(x any) bool {
sr := x.(*ldap.SearchRequest) sr := x.(*ldap.SearchRequest)
return sr.Filter == srm.expected return sr.Filter == srm.expected
} }

View File

@ -235,7 +235,7 @@ func newCryptoGenerateCmd(category, algorithm string) (cmd *cobra.Command) {
func cryptoGenerateRunE(cmd *cobra.Command, args []string) (err error) { func cryptoGenerateRunE(cmd *cobra.Command, args []string) (err error) {
var ( var (
privateKey interface{} privateKey any
) )
if privateKey, err = cryptoGenPrivateKeyFromCmd(cmd); err != nil { if privateKey, err = cryptoGenPrivateKeyFromCmd(cmd); err != nil {
@ -251,7 +251,7 @@ func cryptoGenerateRunE(cmd *cobra.Command, args []string) (err error) {
func cryptoCertificateRequestRunE(cmd *cobra.Command, _ []string) (err error) { func cryptoCertificateRequestRunE(cmd *cobra.Command, _ []string) (err error) {
var ( var (
privateKey interface{} privateKey any
) )
if privateKey, err = cryptoGenPrivateKeyFromCmd(cmd); err != nil { if privateKey, err = cryptoGenPrivateKeyFromCmd(cmd); err != nil {
@ -320,10 +320,10 @@ func cryptoCertificateRequestRunE(cmd *cobra.Command, _ []string) (err error) {
return nil return nil
} }
func cryptoCertificateGenerateRunE(cmd *cobra.Command, _ []string, privateKey interface{}) (err error) { func cryptoCertificateGenerateRunE(cmd *cobra.Command, _ []string, privateKey any) (err error) {
var ( var (
template, caCertificate, parent *x509.Certificate template, caCertificate, parent *x509.Certificate
publicKey, caPrivateKey, signatureKey interface{} publicKey, caPrivateKey, signatureKey any
) )
if publicKey = utils.PublicKeyFromPrivateKey(privateKey); publicKey == nil { if publicKey = utils.PublicKeyFromPrivateKey(privateKey); publicKey == nil {
@ -412,7 +412,7 @@ func cryptoCertificateGenerateRunE(cmd *cobra.Command, _ []string, privateKey in
return nil return nil
} }
func cryptoPairGenerateRunE(cmd *cobra.Command, _ []string, privateKey interface{}) (err error) { func cryptoPairGenerateRunE(cmd *cobra.Command, _ []string, privateKey any) (err error) {
var ( var (
privateKeyPath, publicKeyPath string privateKeyPath, publicKeyPath string
pkcs8 bool pkcs8 bool
@ -451,7 +451,7 @@ func cryptoPairGenerateRunE(cmd *cobra.Command, _ []string, privateKey interface
return err return err
} }
var publicKey interface{} var publicKey any
if publicKey = utils.PublicKeyFromPrivateKey(privateKey); publicKey == nil { if publicKey = utils.PublicKeyFromPrivateKey(privateKey); publicKey == nil {
return fmt.Errorf("failed to obtain public key from private key") return fmt.Errorf("failed to obtain public key from private key")

View File

@ -130,7 +130,7 @@ func cryptoGetWritePathsFromCmd(cmd *cobra.Command) (privateKey, publicKey strin
return filepath.Join(dir, private), filepath.Join(dir, public), nil return filepath.Join(dir, private), filepath.Join(dir, public), nil
} }
func cryptoGenPrivateKeyFromCmd(cmd *cobra.Command) (privateKey interface{}, err error) { func cryptoGenPrivateKeyFromCmd(cmd *cobra.Command) (privateKey any, err error) {
switch cmd.Parent().Use { switch cmd.Parent().Use {
case cmdUseRSA: case cmdUseRSA:
var ( var (
@ -170,7 +170,7 @@ func cryptoGenPrivateKeyFromCmd(cmd *cobra.Command) (privateKey interface{}, err
return privateKey, nil return privateKey, nil
} }
func cryptoGetCAFromCmd(cmd *cobra.Command) (privateKey interface{}, cert *x509.Certificate, err error) { func cryptoGetCAFromCmd(cmd *cobra.Command) (privateKey any, cert *x509.Certificate, err error) {
if !cmd.Flags().Changed(cmdFlagNamePathCA) { if !cmd.Flags().Changed(cmdFlagNamePathCA) {
return nil, nil, nil return nil, nil, nil
} }
@ -180,7 +180,7 @@ func cryptoGetCAFromCmd(cmd *cobra.Command) (privateKey interface{}, cert *x509.
ok bool ok bool
certificate interface{} certificate any
) )
if dir, err = cmd.Flags().GetString(cmdFlagNamePathCA); err != nil { if dir, err = cmd.Flags().GetString(cmdFlagNamePathCA); err != nil {

View File

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
) )
func recoverErr(i interface{}) error { func recoverErr(i any) error {
switch v := i.(type) { switch v := i.(type) {
case nil: case nil:
return nil return nil

View File

@ -19,7 +19,7 @@ import (
// StringToMailAddressHookFunc decodes a string into a mail.Address or *mail.Address. // StringToMailAddressHookFunc decodes a string into a mail.Address or *mail.Address.
func StringToMailAddressHookFunc() mapstructure.DecodeHookFuncType { func StringToMailAddressHookFunc() mapstructure.DecodeHookFuncType {
return func(f reflect.Type, t reflect.Type, data interface{}) (value interface{}, err error) { return func(f reflect.Type, t reflect.Type, data any) (value any, err error) {
var ptr bool var ptr bool
if f.Kind() != reflect.String { if f.Kind() != reflect.String {
@ -65,7 +65,7 @@ func StringToMailAddressHookFunc() mapstructure.DecodeHookFuncType {
// StringToURLHookFunc converts string types into a url.URL or *url.URL. // StringToURLHookFunc converts string types into a url.URL or *url.URL.
func StringToURLHookFunc() mapstructure.DecodeHookFuncType { func StringToURLHookFunc() mapstructure.DecodeHookFuncType {
return func(f reflect.Type, t reflect.Type, data interface{}) (value interface{}, err error) { return func(f reflect.Type, t reflect.Type, data any) (value any, err error) {
var ptr bool var ptr bool
if f.Kind() != reflect.String { if f.Kind() != reflect.String {
@ -111,7 +111,7 @@ func StringToURLHookFunc() mapstructure.DecodeHookFuncType {
// ToTimeDurationHookFunc converts string and integer types to a time.Duration. // ToTimeDurationHookFunc converts string and integer types to a time.Duration.
func ToTimeDurationHookFunc() mapstructure.DecodeHookFuncType { func ToTimeDurationHookFunc() mapstructure.DecodeHookFuncType {
return func(f reflect.Type, t reflect.Type, data interface{}) (value interface{}, err error) { return func(f reflect.Type, t reflect.Type, data any) (value any, err error) {
var ptr bool var ptr bool
switch f.Kind() { switch f.Kind() {
@ -172,7 +172,7 @@ func ToTimeDurationHookFunc() mapstructure.DecodeHookFuncType {
// StringToRegexpHookFunc decodes a string into a *regexp.Regexp or regexp.Regexp. // StringToRegexpHookFunc decodes a string into a *regexp.Regexp or regexp.Regexp.
func StringToRegexpHookFunc() mapstructure.DecodeHookFuncType { func StringToRegexpHookFunc() mapstructure.DecodeHookFuncType {
return func(f reflect.Type, t reflect.Type, data interface{}) (value interface{}, err error) { return func(f reflect.Type, t reflect.Type, data any) (value any, err error) {
var ptr bool var ptr bool
if f.Kind() != reflect.String { if f.Kind() != reflect.String {
@ -218,7 +218,7 @@ func StringToRegexpHookFunc() mapstructure.DecodeHookFuncType {
// StringToAddressHookFunc decodes a string into an Address or *Address. // StringToAddressHookFunc decodes a string into an Address or *Address.
func StringToAddressHookFunc() mapstructure.DecodeHookFuncType { func StringToAddressHookFunc() mapstructure.DecodeHookFuncType {
return func(f reflect.Type, t reflect.Type, data interface{}) (value interface{}, err error) { return func(f reflect.Type, t reflect.Type, data any) (value any, err error) {
var ptr bool var ptr bool
if f.Kind() != reflect.String { if f.Kind() != reflect.String {
@ -258,7 +258,7 @@ func StringToAddressHookFunc() mapstructure.DecodeHookFuncType {
// StringToX509CertificateHookFunc decodes strings to x509.Certificate's. // StringToX509CertificateHookFunc decodes strings to x509.Certificate's.
func StringToX509CertificateHookFunc() mapstructure.DecodeHookFuncType { func StringToX509CertificateHookFunc() mapstructure.DecodeHookFuncType {
return func(f reflect.Type, t reflect.Type, data interface{}) (value interface{}, err error) { return func(f reflect.Type, t reflect.Type, data any) (value interface{}, err error) {
if f.Kind() != reflect.String { if f.Kind() != reflect.String {
return data, nil return data, nil
} }

View File

@ -993,8 +993,8 @@ func TestStringToX509CertificateHookFunc(t *testing.T) {
testCases := []struct { testCases := []struct {
desc string desc string
have interface{} have any
want interface{} want any
err string err string
decode bool decode bool
}{ }{
@ -1069,8 +1069,8 @@ func TestStringToX509CertificateChainHookFunc(t *testing.T) {
testCases := []struct { testCases := []struct {
desc string desc string
have interface{} have any
expected interface{} expected any
err, verr string err, verr string
decode bool decode bool
}{ }{

View File

@ -10,7 +10,7 @@ type Deprecation struct {
Key string Key string
NewKey string NewKey string
AutoMap bool AutoMap bool
MapFunc func(value interface{}) interface{} MapFunc func(value any) any
ErrText string ErrText string
} }

View File

@ -11,8 +11,8 @@ import (
) )
// koanfEnvironmentCallback returns a koanf callback to map the environment vars to Configuration keys. // koanfEnvironmentCallback returns a koanf callback to map the environment vars to Configuration keys.
func koanfEnvironmentCallback(keyMap map[string]string, ignoredKeys []string, prefix, delimiter string) func(key, value string) (finalKey string, finalValue interface{}) { func koanfEnvironmentCallback(keyMap map[string]string, ignoredKeys []string, prefix, delimiter string) func(key, value string) (finalKey string, finalValue any) {
return func(key, value string) (finalKey string, finalValue interface{}) { return func(key, value string) (finalKey string, finalValue any) {
if k, ok := keyMap[key]; ok { if k, ok := keyMap[key]; ok {
return k, value return k, value
} }
@ -33,8 +33,8 @@ func koanfEnvironmentCallback(keyMap map[string]string, ignoredKeys []string, pr
} }
// koanfEnvironmentSecretsCallback returns a koanf callback to map the environment vars to Configuration keys. // koanfEnvironmentSecretsCallback returns a koanf callback to map the environment vars to Configuration keys.
func koanfEnvironmentSecretsCallback(keyMap map[string]string, validator *schema.StructValidator) func(key, value string) (finalKey string, finalValue interface{}) { func koanfEnvironmentSecretsCallback(keyMap map[string]string, validator *schema.StructValidator) func(key, value string) (finalKey string, finalValue any) {
return func(key, value string) (finalKey string, finalValue interface{}) { return func(key, value string) (finalKey string, finalValue any) {
k, ok := keyMap[key] k, ok := keyMap[key]
if !ok { if !ok {
return "", nil return "", nil
@ -50,8 +50,8 @@ func koanfEnvironmentSecretsCallback(keyMap map[string]string, validator *schema
} }
} }
func koanfCommandLineWithMappingCallback(mapping map[string]string, includeValidKeys, includeUnchangedKeys bool) func(flag *pflag.Flag) (string, interface{}) { func koanfCommandLineWithMappingCallback(mapping map[string]string, includeValidKeys, includeUnchangedKeys bool) func(flag *pflag.Flag) (string, any) {
return func(flag *pflag.Flag) (string, interface{}) { return func(flag *pflag.Flag) (string, any) {
if !includeUnchangedKeys && !flag.Changed { if !includeUnchangedKeys && !flag.Changed {
return "", nil return "", nil
} }

View File

@ -16,7 +16,7 @@ import (
func TestKoanfEnvironmentCallback(t *testing.T) { func TestKoanfEnvironmentCallback(t *testing.T) {
var ( var (
key string key string
value interface{} value any
) )
keyMap := map[string]string{ keyMap := map[string]string{
@ -46,7 +46,7 @@ func TestKoanfEnvironmentCallback(t *testing.T) {
func TestKoanfSecretCallbackWithValidSecrets(t *testing.T) { func TestKoanfSecretCallbackWithValidSecrets(t *testing.T) {
var ( var (
key string key string
value interface{} value any
) )
keyMap := map[string]string{ keyMap := map[string]string{

View File

@ -15,13 +15,13 @@ func koanfGetKeys(ko *koanf.Koanf) (keys []string) {
keys = ko.Keys() keys = ko.Keys()
for key, value := range ko.All() { for key, value := range ko.All() {
slc, ok := value.([]interface{}) slc, ok := value.([]any)
if !ok { if !ok {
continue continue
} }
for _, item := range slc { for _, item := range slc {
m, mok := item.(map[string]interface{}) m, mok := item.(map[string]any)
if !mok { if !mok {
continue continue
} }
@ -53,7 +53,7 @@ func koanfRemapKeys(val *schema.StructValidator, ko *koanf.Koanf, ds map[string]
return final, nil return final, nil
} }
func koanfRemapKeysStandard(keys map[string]interface{}, val *schema.StructValidator, ds map[string]Deprecation) (keysFinal map[string]interface{}) { func koanfRemapKeysStandard(keys map[string]any, val *schema.StructValidator, ds map[string]Deprecation) (keysFinal map[string]interface{}) {
var ( var (
ok bool ok bool
d Deprecation d Deprecation

View File

@ -19,7 +19,7 @@ func Load(val *schema.StructValidator, sources ...Source) (keys []string, config
} }
// LoadAdvanced is intended to give more flexibility over loading a particular path to a specific interface. // LoadAdvanced is intended to give more flexibility over loading a particular path to a specific interface.
func LoadAdvanced(val *schema.StructValidator, path string, result interface{}, sources ...Source) (keys []string, err error) { func LoadAdvanced(val *schema.StructValidator, path string, result any, sources ...Source) (keys []string, err error) {
if val == nil { if val == nil {
return keys, errNoValidator return keys, errNoValidator
} }
@ -44,7 +44,7 @@ func LoadAdvanced(val *schema.StructValidator, path string, result interface{},
return koanfGetKeys(final), nil return koanfGetKeys(final), nil
} }
func mapHasKey(k string, m map[string]interface{}) bool { func mapHasKey(k string, m map[string]any) bool {
if _, ok := m[k]; ok { if _, ok := m[k]; ok {
return true return true
} }
@ -52,7 +52,7 @@ func mapHasKey(k string, m map[string]interface{}) bool {
return false return false
} }
func unmarshal(ko *koanf.Koanf, val *schema.StructValidator, path string, o interface{}) { func unmarshal(ko *koanf.Koanf, val *schema.StructValidator, path string, o any) {
c := koanf.UnmarshalConf{ c := koanf.UnmarshalConf{
DecoderConfig: &mapstructure.DecoderConfig{ DecoderConfig: &mapstructure.DecoderConfig{
DecodeHook: mapstructure.ComposeDecodeHookFunc( DecodeHook: mapstructure.ComposeDecodeHookFunc(

View File

@ -145,8 +145,8 @@ func (s *CommandLineSource) Load(_ *schema.StructValidator) (err error) {
return s.koanf.Load(posflag.Provider(s.flags, ".", s.koanf), nil) return s.koanf.Load(posflag.Provider(s.flags, ".", s.koanf), nil)
} }
// NewMapSource returns a new map[string]interface{} source. // NewMapSource returns a new map[string]any source.
func NewMapSource(m map[string]interface{}) (source *MapSource) { func NewMapSource(m map[string]any) (source *MapSource) {
return &MapSource{ return &MapSource{
m: m, m: m,
koanf: koanf.New(constDelimiter), koanf: koanf.New(constDelimiter),

View File

@ -38,11 +38,11 @@ type SecretsSource struct {
type CommandLineSource struct { type CommandLineSource struct {
koanf *koanf.Koanf koanf *koanf.Koanf
flags *pflag.FlagSet flags *pflag.FlagSet
callback func(flag *pflag.Flag) (string, interface{}) callback func(flag *pflag.Flag) (string, any)
} }
// MapSource loads configuration from the command line flags. // MapSource loads configuration from the command line flags.
type MapSource struct { type MapSource struct {
m map[string]interface{} m map[string]any
koanf *koanf.Koanf koanf *koanf.Koanf
} }

View File

@ -41,7 +41,7 @@ func WebauthnAssertionGET(ctx *middlewares.AutheliaCtx) {
webauthn.WithAllowedCredentials(user.WebAuthnCredentialDescriptors()), webauthn.WithAllowedCredentials(user.WebAuthnCredentialDescriptors()),
} }
extensions := make(map[string]interface{}) extensions := map[string]any{}
if user.HasFIDOU2F() { if user.HasFIDOU2F() {
extensions["appid"] = w.Config.RPOrigin extensions["appid"] = w.Config.RPOrigin

View File

@ -8,8 +8,8 @@ import (
"github.com/authelia/authelia/v4/internal/session" "github.com/authelia/authelia/v4/internal/session"
) )
func oidcGrantRequests(ar fosite.AuthorizeRequester, consent *model.OAuth2ConsentSession, userSession *session.UserSession) (extraClaims map[string]interface{}) { func oidcGrantRequests(ar fosite.AuthorizeRequester, consent *model.OAuth2ConsentSession, userSession *session.UserSession) (extraClaims map[string]any) {
extraClaims = map[string]interface{}{} extraClaims = map[string]any{}
for _, scope := range consent.GrantedScopes { for _, scope := range consent.GrantedScopes {
if ar != nil { if ar != nil {

View File

@ -95,7 +95,7 @@ func (ctx *AutheliaCtx) ReplyStatusCode(statusCode int) {
} }
// ReplyJSON writes a JSON response. // ReplyJSON writes a JSON response.
func (ctx *AutheliaCtx) ReplyJSON(data interface{}, statusCode int) (err error) { func (ctx *AutheliaCtx) ReplyJSON(data any, statusCode int) (err error) {
var ( var (
body []byte body []byte
) )
@ -246,7 +246,7 @@ func (ctx *AutheliaCtx) ReplyOK() {
} }
// ParseBody parse the request body into the type of value. // ParseBody parse the request body into the type of value.
func (ctx *AutheliaCtx) ParseBody(value interface{}) error { func (ctx *AutheliaCtx) ParseBody(value any) error {
err := json.Unmarshal(ctx.PostBody(), &value) err := json.Unmarshal(ctx.PostBody(), &value)
if err != nil { if err != nil {
@ -267,7 +267,7 @@ func (ctx *AutheliaCtx) ParseBody(value interface{}) error {
} }
// SetJSONBody Set json body. // SetJSONBody Set json body.
func (ctx *AutheliaCtx) SetJSONBody(value interface{}) error { func (ctx *AutheliaCtx) SetJSONBody(value any) error {
return ctx.ReplyJSON(OKResponse{Status: "OK", Data: value}, 0) return ctx.ReplyJSON(OKResponse{Status: "OK", Data: value}, 0)
} }

View File

@ -132,7 +132,7 @@ func IdentityVerificationFinish(args IdentityVerificationFinishArgs, next func(c
} }
token, err := jwt.ParseWithClaims(finishBody.Token, &model.IdentityVerificationClaim{}, token, err := jwt.ParseWithClaims(finishBody.Token, &model.IdentityVerificationClaim{},
func(token *jwt.Token) (interface{}, error) { func(token *jwt.Token) (any, error) {
return []byte(ctx.Configuration.JWTSecret), nil return []byte(ctx.Configuration.JWTSecret), nil
}) })

View File

@ -108,8 +108,8 @@ type IdentityVerificationFinishBody struct {
// OKResponse model of a status OK response. // OKResponse model of a status OK response.
type OKResponse struct { type OKResponse struct {
Status string `json:"status"` Status string `json:"status"`
Data interface{} `json:"data,omitempty"` Data any `json:"data,omitempty"`
} }
// ErrorResponse model of an error response. // ErrorResponse model of an error response.

View File

@ -227,7 +227,7 @@ type OpenIDSession struct {
ChallengeID uuid.UUID `db:"challenge_id"` ChallengeID uuid.UUID `db:"challenge_id"`
ClientID string ClientID string
Extra map[string]interface{} `json:"extra"` Extra map[string]any `json:"extra"`
} }
// Clone copies the OpenIDSession to a new fosite.Session. // Clone copies the OpenIDSession to a new fosite.Session.

View File

@ -49,7 +49,7 @@ func (ip IP) Value() (value driver.Value, err error) {
} }
// Scan is the IP implementation of the sql.Scanner. // Scan is the IP implementation of the sql.Scanner.
func (ip *IP) Scan(src interface{}) (err error) { func (ip *IP) Scan(src any) (err error) {
if src == nil { if src == nil {
return fmt.Errorf(errFmtScanNil, ip) return fmt.Errorf(errFmtScanNil, ip)
} }
@ -85,7 +85,7 @@ func (ip NullIP) Value() (value driver.Value, err error) {
} }
// Scan is the NullIP implementation of the sql.Scanner. // Scan is the NullIP implementation of the sql.Scanner.
func (ip *NullIP) Scan(src interface{}) (err error) { func (ip *NullIP) Scan(src any) (err error) {
if src == nil { if src == nil {
ip.IP = nil ip.IP = nil
return nil return nil
@ -128,7 +128,7 @@ func (b Base64) Value() (value driver.Value, err error) {
} }
// Scan is the Base64 implementation of the sql.Scanner. // Scan is the Base64 implementation of the sql.Scanner.
func (b *Base64) Scan(src interface{}) (err error) { func (b *Base64) Scan(src any) (err error) {
if src == nil { if src == nil {
return fmt.Errorf(errFmtScanNil, b) return fmt.Errorf(errFmtScanNil, b)
} }
@ -158,7 +158,7 @@ type StartupCheck interface {
type StringSlicePipeDelimited []string type StringSlicePipeDelimited []string
// Scan is the StringSlicePipeDelimited implementation of the sql.Scanner. // Scan is the StringSlicePipeDelimited implementation of the sql.Scanner.
func (s *StringSlicePipeDelimited) Scan(value interface{}) (err error) { func (s *StringSlicePipeDelimited) Scan(value any) (err error) {
var nullStr sql.NullString var nullStr sql.NullString
if err = nullStr.Scan(value); err != nil { if err = nullStr.Scan(value); err != nil {

View File

@ -44,7 +44,7 @@ func TestNewSessionWithAuthorizeRequest(t *testing.T) {
}, },
} }
extra := map[string]interface{}{ extra := map[string]any{
"preferred_username": "john", "preferred_username": "john",
} }

View File

@ -122,7 +122,7 @@ func ConvertDERToPEM(der []byte, blockType PEMBlockType) ([]byte, error) {
return buf.Bytes(), nil return buf.Bytes(), nil
} }
func publicKey(privateKey interface{}) interface{} { func publicKey(privateKey any) any {
switch k := privateKey.(type) { switch k := privateKey.(type) {
case *rsa.PrivateKey: case *rsa.PrivateKey:
return &k.PublicKey return &k.PublicKey
@ -137,7 +137,7 @@ func publicKey(privateKey interface{}) interface{} {
// PrivateKeyBuilder interface for a private key builder. // PrivateKeyBuilder interface for a private key builder.
type PrivateKeyBuilder interface { type PrivateKeyBuilder interface {
Build() (interface{}, error) Build() (any, error)
} }
// RSAKeyBuilder builder of RSA private key. // RSAKeyBuilder builder of RSA private key.
@ -152,7 +152,7 @@ func (rkb RSAKeyBuilder) WithKeySize(bits int) RSAKeyBuilder {
} }
// Build a RSA private key. // Build a RSA private key.
func (rkb RSAKeyBuilder) Build() (interface{}, error) { func (rkb RSAKeyBuilder) Build() (any, error) {
return rsa.GenerateKey(rand.Reader, rkb.keySizeInBits) return rsa.GenerateKey(rand.Reader, rkb.keySizeInBits)
} }
@ -160,7 +160,7 @@ func (rkb RSAKeyBuilder) Build() (interface{}, error) {
type Ed25519KeyBuilder struct{} type Ed25519KeyBuilder struct{}
// Build an Ed25519 private key. // Build an Ed25519 private key.
func (ekb Ed25519KeyBuilder) Build() (interface{}, error) { func (ekb Ed25519KeyBuilder) Build() (any, error) {
_, priv, err := ed25519.GenerateKey(rand.Reader) _, priv, err := ed25519.GenerateKey(rand.Reader)
return priv, err return priv, err
} }
@ -177,7 +177,7 @@ func (ekb ECDSAKeyBuilder) WithCurve(curve elliptic.Curve) ECDSAKeyBuilder {
} }
// Build an ECDSA private key. // Build an ECDSA private key.
func (ekb ECDSAKeyBuilder) Build() (interface{}, error) { func (ekb ECDSAKeyBuilder) Build() (any, error) {
return ecdsa.GenerateKey(ekb.curve, rand.Reader) return ecdsa.GenerateKey(ekb.curve, rand.Reader)
} }
@ -213,7 +213,7 @@ func ParseX509FromPEM(data []byte) (key any, err error) {
} }
// CastX509AsCertificate converts an interface to an *x509.Certificate. // CastX509AsCertificate converts an interface to an *x509.Certificate.
func CastX509AsCertificate(c interface{}) (certificate *x509.Certificate, ok bool) { func CastX509AsCertificate(c any) (certificate *x509.Certificate, ok bool) {
switch t := c.(type) { switch t := c.(type) {
case x509.Certificate: case x509.Certificate:
return &t, true return &t, true
@ -225,7 +225,7 @@ func CastX509AsCertificate(c interface{}) (certificate *x509.Certificate, ok boo
} }
// IsX509PrivateKey returns true if the provided interface is an rsa.PrivateKey, ecdsa.PrivateKey, or ed25519.PrivateKey. // IsX509PrivateKey returns true if the provided interface is an rsa.PrivateKey, ecdsa.PrivateKey, or ed25519.PrivateKey.
func IsX509PrivateKey(i interface{}) bool { func IsX509PrivateKey(i any) bool {
switch i.(type) { switch i.(type) {
case rsa.PrivateKey, *rsa.PrivateKey, ecdsa.PrivateKey, *ecdsa.PrivateKey, ed25519.PrivateKey, *ed25519.PrivateKey: case rsa.PrivateKey, *rsa.PrivateKey, ecdsa.PrivateKey, *ecdsa.PrivateKey, ed25519.PrivateKey, *ed25519.PrivateKey:
return true return true
@ -328,7 +328,7 @@ func WriteCertificateBytesToPEM(cert []byte, path string, csr bool) (err error)
} }
// WriteKeyToPEM writes a key that can be encoded as a PEM to a file in the PEM format. // WriteKeyToPEM writes a key that can be encoded as a PEM to a file in the PEM format.
func WriteKeyToPEM(key interface{}, path string, pkcs8 bool) (err error) { func WriteKeyToPEM(key any, path string, pkcs8 bool) (err error) {
pemBlock, err := PEMBlockFromX509Key(key, pkcs8) pemBlock, err := PEMBlockFromX509Key(key, pkcs8)
if err != nil { if err != nil {
return err return err
@ -349,7 +349,7 @@ func WriteKeyToPEM(key interface{}, path string, pkcs8 bool) (err error) {
} }
// PEMBlockFromX509Key turns a PublicKey or PrivateKey into a pem.Block. // PEMBlockFromX509Key turns a PublicKey or PrivateKey into a pem.Block.
func PEMBlockFromX509Key(key interface{}, pkcs8 bool) (pemBlock *pem.Block, err error) { func PEMBlockFromX509Key(key any, pkcs8 bool) (pemBlock *pem.Block, err error) {
var ( var (
data []byte data []byte
blockType string blockType string
@ -491,7 +491,7 @@ func EllipticCurveFromString(curveString string) (curve elliptic.Curve) {
} }
// PublicKeyFromPrivateKey returns a PublicKey when provided with a PrivateKey. // PublicKeyFromPrivateKey returns a PublicKey when provided with a PrivateKey.
func PublicKeyFromPrivateKey(privateKey interface{}) (publicKey interface{}) { func PublicKeyFromPrivateKey(privateKey any) (publicKey any) {
switch k := privateKey.(type) { switch k := privateKey.(type) {
case *rsa.PrivateKey: case *rsa.PrivateKey:
return &k.PublicKey return &k.PublicKey