You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds an ErrorCode struct which provides a return code to os.Exit in Main.
Four manifest errors values have been defined
ErrUsage: for usage errors that can be corrected by the user
ErrIntenal: an internal error that is beyond the control of the user
ErrUnimplemented: an unimplemented feature
ErrUnknown: an unknown error has occurred
The entropylex command has been refactored to use these errors.
Key Changes
The OutputFile and InputFile functions have been moved to their on files, outputfile.go and inputfile.go. The accompanying unit tests have also been moved to outputfile_test.go and inputfile_test.go.
now using go1.27
enhances the "clean" make target
Design Rationale
The errors are properly isolated to the entropylex command, since they convey return result only relevant to the cli command.
High-effort review of the diff vs main. Six findings, most severe first.
🔴 Blocking / correctness
1. Test imports a bare uuid package that only exists locally — entropylex/cmd/entropylex/outputfile_test.go:7
The test imports "uuid", which resolves to a manually-added /usr/local/go/src/uuid. go.mod dropped github.com/google/uu id, so on any clean toolchain (CI included) the package won't compile — package uuid is not in std — and the whole package' s tests fail before running. Restore github.com/google/uuid.NewString().
2. Invalid -b now truncates the output file (data loss) — entropylex/cmd/entropylex/command.go:95
Deleting the bit-depth flag Validator moved validation into the Action, which runs OutputFile() (create/truncate) before rejecting a bad -b. So entropylex -b 42 -o existing.dat --force truncates existing.dat to 0 bytes, then errors. Previou sly the flag validator rejected it at parse time, before any file was touched.
3. make clean wipes the shared module cache — Makefile:149 go clean -i -r -cache -testcache -modcache -fuzzcache — the -modcache blows away $GOMODCACHE for every Go project on t he machine, forcing a full re-download next build. -i -r also removes installed archives for all deps recursively.
🟡 Consistency / coverage
4. %s instead of %w breaks the error chain — entropylex/cmd/entropylex/command.go:97 fmt.Errorf("%w: %s", ErrUsage, err) on the OutputFile path drops err from the unwrap chain, while the adjacent InputFile p ath (command.go:113) correctly uses %w: %w. Two otherwise-identical paths behave differently under errors.Is/As.
5. Usage errors no longer print command help — entropylex/cmd/entropylex/command.go:96
Removing DefaultShowRootCommandHelp means a usage error now prints only the one-line message from main.go, no usage guidan ce. Possibly intentional (tests were updated) — worth confirming the UX is intended.
6. Test_NewEntropyLex8 is an empty // TODO that always passes — entropylex/cmd/entropylex/entropylex8_test.go:8
The three new ErrInternal-wrapping branches added to NewEntropyLex8 in this PR are untested; the placeholder reports succe ss without exercising any of them.
High-effort review of the diff vs main. Six findings, most severe first.
🔴 Blocking / correctness
1. Test imports a bare uuid package that only exists locally — entropylex/cmd/entropylex/outputfile_test.go:7 The test imports "uuid", which resolves to a manually-added /usr/local/go/src/uuid. go.mod dropped github.com/google/uu id, so on any clean toolchain (CI included) the package won't compile — package uuid is not in std — and the whole package' s tests fail before running. Restore github.com/google/uuid.NewString().
This is incorrect. go1.27 now includes a uuid package.
2. Invalid -b now truncates the output file (data loss) — entropylex/cmd/entropylex/command.go:95 Deleting the bit-depth flag Validator moved validation into the Action, which runs OutputFile() (create/truncate) before rejecting a bad -b. So entropylex -b 42 -o existing.dat --force truncates existing.dat to 0 bytes, then errors. Previou sly the flag validator rejected it at parse time, before any file was touched.
I'll fix this.
3. make clean wipes the shared module cache — Makefile:149go clean -i -r -cache -testcache -modcache -fuzzcache — the -modcache blows away $GOMODCACHE for every Go project on t he machine, forcing a full re-download next build. -i -r also removes installed archives for all deps recursively.
I'm fine withe the entire module cache being destroyed.
🟡 Consistency / coverage
4. %s instead of %w breaks the error chain — entropylex/cmd/entropylex/command.go:97fmt.Errorf("%w: %s", ErrUsage, err) on the OutputFile path drops err from the unwrap chain, while the adjacent InputFile p ath (command.go:113) correctly uses %w: %w. Two otherwise-identical paths behave differently under errors.Is/As.
I'll fix this.
5. Usage errors no longer print command help — entropylex/cmd/entropylex/command.go:96 Removing DefaultShowRootCommandHelp means a usage error now prints only the one-line message from main.go, no usage guidan ce. Possibly intentional (tests were updated) — worth confirming the UX is intended.
This is intended.
6. Test_NewEntropyLex8 is an empty // TODO that always passes — entropylex/cmd/entropylex/entropylex8_test.go:8 The three new ErrInternal-wrapping branches added to NewEntropyLex8 in this PR are untested; the placeholder reports succe ss without exercising any of them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Fixes #29
Summary
Adds an
ErrorCodestruct which provides a return code toos.ExitinMain.Four manifest errors values have been defined
The entropylex command has been refactored to use these errors.
Key Changes
OutputFileandInputFilefunctions have been moved to their on files, outputfile.go and inputfile.go. The accompanying unit tests have also been moved to outputfile_test.go and inputfile_test.go.Design Rationale
The errors are properly isolated to the entropylex command, since they convey return result only relevant to the cli command.
Test Plan