Merge pull request #204 from Rain-kl/feat/save-strategy

新增功能: 重名文件时选择保存策略 - 重命名,覆盖,跳过
This commit is contained in:
Ryan
2026-05-20 16:11:00 +08:00
committed by GitHub
parent 0982abe7bc
commit 62e4a08e28
20 changed files with 441 additions and 48 deletions

View File

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

View File

@@ -14,12 +14,15 @@ import (
const (
// ContentLength is a ContextKey of type content-length.
ContentLength ContextKey = "content-length"
// OverwriteExisting is a ContextKey of type overwrite-existing.
OverwriteExisting ContextKey = "overwrite-existing"
)
var ErrInvalidContextKey = fmt.Errorf("not a valid ContextKey, try [%s]", strings.Join(_ContextKeyNames, ", "))
var _ContextKeyNames = []string{
string(ContentLength),
string(OverwriteExisting),
}
// ContextKeyNames returns a list of possible string values of ContextKey.
@@ -33,6 +36,7 @@ func ContextKeyNames() []string {
func ContextKeyValues() []ContextKey {
return []ContextKey{
ContentLength,
OverwriteExisting,
}
}
@@ -49,7 +53,8 @@ func (x ContextKey) IsValid() bool {
}
var _ContextKeyValue = map[string]ContextKey{
"content-length": ContentLength,
"content-length": ContentLength,
"overwrite-existing": OverwriteExisting,
}
// ParseContextKey attempts to convert a string to a ContextKey.