mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-06-28 02:31:34 +08:00
refactor: replace key package with ctxkey for context keys
This commit is contained in:
5
pkg/enums/ctxkey/context_key.go
Normal file
5
pkg/enums/ctxkey/context_key.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package ctxkey
|
||||
|
||||
//go:generate go-enum --values --names --flag --nocase --noprefix
|
||||
// ENUM(content-length)
|
||||
type ContextKey string
|
||||
@@ -4,7 +4,7 @@
|
||||
// Build Date: 2025-03-18T23:42:14Z
|
||||
// Built By: goreleaser
|
||||
|
||||
package key
|
||||
package ctxkey
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -12,14 +12,14 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// ContextKeyContentLength is a ContextKey of type content-length.
|
||||
ContextKeyContentLength ContextKey = "content-length"
|
||||
// ContentLength is a ContextKey of type content-length.
|
||||
ContentLength ContextKey = "content-length"
|
||||
)
|
||||
|
||||
var ErrInvalidContextKey = fmt.Errorf("not a valid ContextKey, try [%s]", strings.Join(_ContextKeyNames, ", "))
|
||||
|
||||
var _ContextKeyNames = []string{
|
||||
string(ContextKeyContentLength),
|
||||
string(ContentLength),
|
||||
}
|
||||
|
||||
// ContextKeyNames returns a list of possible string values of ContextKey.
|
||||
@@ -32,7 +32,7 @@ func ContextKeyNames() []string {
|
||||
// ContextKeyValues returns a list of the values for ContextKey
|
||||
func ContextKeyValues() []ContextKey {
|
||||
return []ContextKey{
|
||||
ContextKeyContentLength,
|
||||
ContentLength,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ func (x ContextKey) IsValid() bool {
|
||||
}
|
||||
|
||||
var _ContextKeyValue = map[string]ContextKey{
|
||||
"content-length": ContextKeyContentLength,
|
||||
"content-length": ContentLength,
|
||||
}
|
||||
|
||||
// ParseContextKey attempts to convert a string to a ContextKey.
|
||||
@@ -1,5 +0,0 @@
|
||||
package key
|
||||
|
||||
//go:generate go-enum --values --names --flag --nocase
|
||||
// ENUM(content-length)
|
||||
type ContextKey string
|
||||
Reference in New Issue
Block a user