-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: update the sprig to sprout changes notes according to this PR
- Loading branch information
Showing
3 changed files
with
84 additions
and
74 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Migration Notes for Sprout Library | ||
This document outlines the key differences and migration changes between the | ||
Sprig and Sprout libraries. The changes are designed to enhance stability and | ||
usability in the Sprout library. | ||
|
||
This document will help contributors and maintainers understand the changes made | ||
between the fork date and version 1.0.0 of the Sprout library. | ||
|
||
It will be updated to reflect changes in future versions of the library. | ||
|
||
This document will also assist in creating the migration guide when version 1.0 is ready. | ||
|
||
|
||
## Error Handling Enhancements | ||
### General Error Handling | ||
In Sprig, errors within certain functions cause a panic. | ||
In contrast, Sprout opts for returning nil or an empty value, improving safety | ||
and predictability. | ||
|
||
**Old Behavior (Sprig)**: Triggers a panic on error | ||
```go | ||
if err != nil { | ||
panic("deepCopy error: " + err.Error()) | ||
} | ||
``` | ||
|
||
**New Behavior (Sprout)**: Returns nil or an empty value on error | ||
```go | ||
if err != nil { | ||
return nil, err | ||
} | ||
``` | ||
|
||
Methods that previously caused a panic in Sprig : | ||
- DeepCopy | ||
- MustDeepCopy | ||
- ToRawJson | ||
- Append | ||
- Prepend | ||
- Concat | ||
- Chunk | ||
- Uniq | ||
- Compact | ||
- Slice | ||
- Without | ||
- Rest | ||
- Initial | ||
- Reverse | ||
- First | ||
- Last | ||
- Has | ||
- Dig | ||
- RandAlphaNumeric | ||
- RandAlpha | ||
- RandAscii | ||
- RandNumeric | ||
- RandBytes | ||
|
||
## Function-Specific Changes | ||
|
||
### MustDeepCopy | ||
|
||
- **Sprig**: Accepts `nil` input, causing an internal panic. | ||
- **Sprout**: Returns `nil` if input is `nil`, avoiding panic. | ||
|
||
## Rand Functions | ||
|
||
- **Sprig**: Causes an internal panic if the length parameter is zero. | ||
- **Sprout**: Returns an empty string if the length is zero, ensuring stability. | ||
|
||
## DateAgo | ||
|
||
- **Sprig**: Does not support int32 and *time.Time; returns "0s". | ||
- **Sprout**: Supports int32 and *time.Time and returns the correct duration. | ||
|
||
## DateRound | ||
- **Sprig**: Returns a corrected duration in positive form, even for negative inputs. | ||
- **Sprout**: Accurately returns the duration, preserving the sign of the input. | ||
|
||
## Base32Decode / Base64Decode | ||
- **Sprig**: Decoding functions return the error string when the input is not a valid base64 encoded string. | ||
- **Sprout**: Decoding functions return an empty string if the input is not a valid base64 encoded string, simplifying error handling. |
This file contains 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