docs: add package and doc comments for exported identifiers
Document every exported type, function and method in the migration, storage and cephfsnative packages and add package comments for migration and the cephmig command, following the commentary rules of Effective Go. Comments on unexported helpers now start with the name they describe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7413b9a43a
commit
c2ef7a6c3b
12 files changed
+150
-7
No files matched your search
@@ -13,18 +13,28 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Executor runs an external command, writing its standard output to the
|
||||
// given writer.
|
||||
type Executor interface {
|
||||
Exec(context.Context, io.Writer, string, ...string) error
|
||||
}
|
||||
|
||||
// Process is the Executor used in production. It runs commands in their own
|
||||
// process group and mirrors their standard error to Stderr, if set.
|
||||
type Process struct{ Stderr io.Writer }
|
||||
|
||||
// ProcessError reports a failed external command. Diagnostic holds the tail
|
||||
// of its standard error; the arguments are deliberately omitted.
|
||||
type ProcessError struct {
|
||||
Name string
|
||||
Err error
|
||||
Diagnostic string
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e *ProcessError) Error() string { return fmt.Sprintf("%s failed: %v", e.Name, e.Err) }
|
||||
|
||||
// Unwrap returns the underlying error.
|
||||
func (e *ProcessError) Unwrap() error { return e.Err }
|
||||
|
||||
type tailBuffer struct{ data []byte }
|
||||
@@ -43,6 +53,8 @@ func (b *tailBuffer) Write(p []byte) (int, error) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// Exec runs name with args under ctx. On cancellation the whole process
|
||||
// group receives SIGTERM.
|
||||
func (p Process) Exec(ctx context.Context, out io.Writer, name string, args ...string) error {
|
||||
cmd := exec.CommandContext(ctx, name, args...)
|
||||
cmd.Stdout = out
|
||||
|
||||
Reference in new issue
Block a user