refactor: replace key package with ctxkey for context keys

This commit is contained in:
krau
2025-06-17 22:19:06 +08:00
parent eb6f8675a4
commit 4df2c5a06d
8 changed files with 21 additions and 21 deletions

View File

@@ -0,0 +1,5 @@
package ctxkey
//go:generate go-enum --values --names --flag --nocase --noprefix
// ENUM(content-length)
type ContextKey string

View File

@@ -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.

View File

@@ -1,5 +0,0 @@
package key
//go:generate go-enum --values --names --flag --nocase
// ENUM(content-length)
type ContextKey string