Skip to content

Commit 0ba590f

Browse files
committed
docs: streamline documentation and enhance main function usage
- Add a usage example for TitleCasedName and MD5Hash in the main function - Remove the entire API reference and additional notes section from the documentation Signed-off-by: appleboy <[email protected]>
1 parent 6a159b8 commit 0ba590f

File tree

1 file changed

+3
-48
lines changed

1 file changed

+3
-48
lines changed

convert/README.md

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ func main() {
129129

130130
// Convert to TitleCase
131131
title := convert.TitleCasedName("foo_bar_test")
132-
5 hash
132+
fmt.Println(title) // Output: FooBarTest
133+
134+
// MD5 hash
133135
hash := convert.MD5Hash("hello world")
134136
fmt.Println(hash) // Output: 5d41402abc4b2a76b9719d911017c592
135137
}
@@ -174,50 +176,3 @@ func main() {
174176
fmt.Println(utf8Str) // Output: 你好
175177
}
176178
```
177-
178-
## API Reference
179-
180-
### Basic Type Conversions
181-
182-
- `ToString(value interface{}) string` - Converts any type to string
183-
- `ToBool(value interface{}) bool` - Converts various types to boolean
184-
- `ToInt(value interface{}) interface{}` - Converts to int, returns nil if fails
185-
- `ToFloat(value interface{}) interface{}` - Converts to float64
186-
187-
### Pointer Utilities
188-
189-
- `ToPtr[T any](value T) *T` - Converts value to pointer
190-
- `FromPtr[T any](ptr *T) T` - Converts pointer to value (zero value if nil)
191-
192-
### Collection Conversions
193-
194-
- `SliceToPtrSlice[T any](src []T) []*T` - Converts slice to pointer slice
195-
- `PtrSliceToSlice[T any](src []*T) []T` - Converts pointer slice to values
196-
- `MapToPtrMap[T any](src map[string]T) map[string]*T` - Converts map to pointer map
197-
- `PtrMapToMap[T any](src map[string]*T) map[string]T` - Converts pointer map to values
198-
199-
### String Utilities
200-
201-
- `MD5Hash(text string) string` - Computes MD5 hash (32-char hex string)
202-
- `SnakeCasedName(name string) string` - Converts to snake_case
203-
- `TitleCasedName(name string) string` - Converts snake_case to TitleCase
204-
205-
### Binary Conversion
206-
207-
- `Float64ToByte(f float64) []byte` - Converts float64 to 8-byte BigEndian slice
208-
- `ByteToFloat64(bytes []byte) float64` - Converts 8-byte slice to float64
209-
210-
### Encoding Conversion
211-
212-
- `ConvertBig5ToUTF8(s string) string` - Converts Big5 encoded string to UTF-8
213-
214-
## Notes
215-
216-
- `ToInt()` and `ToFloat()` return `interface{}` (nil on failure) for type safety
217-
- String utilities support Unicode characters but only affect English letters
218-
- Binary conversion uses BigEndian byte order
219-
- Collection conversions handle nil pointers gracefully
220-
- MD5 hashing is for non-cryptographic purposes only
221-
fmt.Println(title) // Output: FooBarTest
222-
223-
// MD

0 commit comments

Comments
 (0)