From f1247b104a0dba8226c443d876737ee924db6a1d Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Fri, 21 Mar 2025 14:58:42 +0800 Subject: misc: Remove underscores --- misc/misc.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'misc/misc.go') diff --git a/misc/misc.go b/misc/misc.go index 8eb76b9..2de1b7f 100644 --- a/misc/misc.go +++ b/misc/misc.go @@ -6,32 +6,32 @@ import ( "strings" ) -// Pointerize_first returns the address of its first argument, and the value of +// PointerizeFirst returns the address of its first argument, and the value of // its second argument. This is useful to for taking the address of the // non-error return value of a function that also has an error return value. -func Pointerize_first[T1 any, T2 any](x1 T1, x2 T2) (*T1, T2) { +func PointerizeFirst[T1 any, T2 any](x1 T1, x2 T2) (*T1, T2) { return &x1, x2 } -// Copy_map the map src to dst without clearing existing items in dst. -func Copy_map[K comparable, V any](dst map[K]V, src map[K]V) { +// CopyMap the map src to dst without clearing existing items in dst. +func CopyMap[K comparable, V any](dst map[K]V, src map[K]V) { for k, v := range src { dst[k] = v } } -// String_to_byte_ptr returns a pointer to the first byte of a string. It +// StringToBytePtr returns a pointer to the first byte of a string. It // ensures that the returned pointer is null-terminated. -func String_to_byte_ptr(s string) (*byte, error) { +func StringToBytePtr(s string) (*byte, error) { // If the string already contains a null then whoever attempts to // interpret this as a null-terminated string won't be able to see the // whole string. This is probably not expected by the caller. if strings.IndexByte(s, 0) != -1 { - return nil, Err_null_byte + return nil, ErrNullByte } buf := make([]byte, len(s)+1) // Zeros them out... copy(buf, s) // ... so the last byte would be null. return &buf[0], nil } -var Err_null_byte = errors.New("string contains null byte") +var ErrNullByte = errors.New("string contains null byte") -- cgit v1.2.3