refactor: move V1 code into v1/ subdirectory

- git mv cmd/ internal/ pkg/ test/ go.mod go.sum Makefile build.sh docs/ v1/
- Create v1/README.md with V1 documentation
- Update root README for V1 + V2 structure
- V1 still builds (cd v1 && go build ./cmd/hostkeeper) and 105 tests pass
- Root is now clean for V2 development
This commit is contained in:
swanadiva
2026-07-07 11:56:27 +07:00
parent 8ebdebedc8
commit 847989df75
68 changed files with 58 additions and 116 deletions
+48
View File
@@ -0,0 +1,48 @@
package errors
import (
"fmt"
)
// Error codes
const (
ErrHostNotFound = "HOST_NOT_FOUND"
ErrAuthFailed = "AUTH_FAILED"
ErrConnectionTimeout = "CONNECTION_TIMEOUT"
ErrInvalidConfig = "INVALID_CONFIG"
ErrKeyNotFound = "KEY_NOT_FOUND"
ErrPermissionDenied = "PERMISSION_DENIED"
ErrFileCorrupted = "FILE_CORRUPTED"
ErrInvalidCredentials = "INVALID_CREDENTIALS"
)
// AppError represents an application error with code, message, cause, and hints
type AppError struct {
Code string
Message string
Cause error
Hints []string
}
// Error implements the error interface
func (e *AppError) Error() string {
if e.Cause != nil {
return fmt.Sprintf("[%s] %s: %v", e.Code, e.Message, e.Cause)
}
return fmt.Sprintf("[%s] %s", e.Code, e.Message)
}
// Unwrap returns the underlying cause for use with errors.Is/errors.As
func (e *AppError) Unwrap() error {
return e.Cause
}
// NewAppError creates a new application error
func NewAppError(code, message string, cause error, hints []string) *AppError {
return &AppError{
Code: code,
Message: message,
Cause: cause,
Hints: hints,
}
}