diff --git a/concurrency.go b/concurrency.go index 594db10..83bb248 100644 --- a/concurrency.go +++ b/concurrency.go @@ -20,7 +20,7 @@ func (s *synchronize) Do(cb func()) { // Play: https://go.dev/play/p/X3cqROSpQmu func Synchronize(opt ...sync.Locker) *synchronize { //nolint:revive if len(opt) > 1 { - panic("unexpected arguments") + panic("lo.Synchronize: unexpected arguments") } else if len(opt) == 0 { opt = append(opt, &sync.Mutex{}) } diff --git a/concurrency_test.go b/concurrency_test.go index 2fa5834..887ba86 100644 --- a/concurrency_test.go +++ b/concurrency_test.go @@ -55,7 +55,7 @@ func TestSynchronize(t *testing.T) { // check we don't accept multiple arguments { - is.PanicsWithValue("unexpected arguments", func() { + is.PanicsWithValue("lo.Synchronize: unexpected arguments", func() { mu := &sync.Mutex{} Synchronize(mu, mu, mu) }) diff --git a/map.go b/map.go index f38bbc9..950bb45 100644 --- a/map.go +++ b/map.go @@ -252,7 +252,7 @@ func Assign[K comparable, V any, Map ~map[K]V](maps ...Map) Map { // Play: https://go.dev/play/p/X_YQL6mmoD- func ChunkEntries[K comparable, V any](m map[K]V, size int) []map[K]V { if size <= 0 { - panic("The chunk size must be greater than 0") + panic("lo.ChunkEntries: size must be greater than 0") } count := len(m) diff --git a/map_test.go b/map_test.go index f6dbec1..9c46b46 100644 --- a/map_test.go +++ b/map_test.go @@ -354,10 +354,10 @@ func TestChunkEntries(t *testing.T) { is.Len(result4, expectedCount4) is.Len(result5, expectedCount5) - is.PanicsWithValue("The chunk size must be greater than 0", func() { + is.PanicsWithValue("lo.ChunkEntries: size must be greater than 0", func() { ChunkEntries(map[string]int{"a": 1}, 0) }) - is.PanicsWithValue("The chunk size must be greater than 0", func() { + is.PanicsWithValue("lo.ChunkEntries: size must be greater than 0", func() { ChunkEntries(map[string]int{"a": 1}, -1) }) diff --git a/slice.go b/slice.go index 4b84d44..21d60aa 100644 --- a/slice.go +++ b/slice.go @@ -208,7 +208,7 @@ func GroupByMap[T any, K comparable, V any](collection []T, iteratee func(item T // Play: https://go.dev/play/p/kEMkFbdu85g func Chunk[T any, Slice ~[]T](collection Slice, size int) []Slice { if size <= 0 { - panic("Second parameter must be greater than 0") + panic("lo.Chunk: size must be greater than 0") } chunksNum := len(collection) / size diff --git a/slice_test.go b/slice_test.go index 45fa716..2c6450f 100644 --- a/slice_test.go +++ b/slice_test.go @@ -318,7 +318,7 @@ func TestChunk(t *testing.T) { is.Equal([][]int{{0, 1}, {2, 3}, {4, 5}, {6}}, result2) is.Equal([][]int{}, result3) is.Equal([][]int{{0}}, result4) - is.PanicsWithValue("Second parameter must be greater than 0", func() { + is.PanicsWithValue("lo.Chunk: size must be greater than 0", func() { Chunk([]int{0}, 0) }) diff --git a/string.go b/string.go index 48353f2..f4aa85c 100644 --- a/string.go +++ b/string.go @@ -34,10 +34,10 @@ var ( // Play: https://go.dev/play/p/rRseOQVVum4 func RandomString(size int, charset []rune) string { if size <= 0 { - panic("lo.RandomString: Size parameter must be greater than 0") + panic("lo.RandomString: size must be greater than 0") } if len(charset) == 0 { - panic("lo.RandomString: Charset parameter must not be empty") + panic("lo.RandomString: charset must not be empty") } // see https://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-go @@ -118,7 +118,7 @@ func Substring[T ~string](str T, offset int, length uint) T { // Play: https://go.dev/play/p/__FLTuJVz54 func ChunkString[T ~string](str T, size int) []T { if size <= 0 { - panic("lo.ChunkString: Size parameter must be greater than 0") + panic("lo.ChunkString: size must be greater than 0") } if len(str) == 0 { diff --git a/string_test.go b/string_test.go index e8ae8df..4b45487 100644 --- a/string_test.go +++ b/string_test.go @@ -27,8 +27,8 @@ func TestRandomString(t *testing.T) { is.Equal(100, RuneLength(str3)) is.Subset(noneUtf8Charset, []rune(str3)) - is.PanicsWithValue("lo.RandomString: Charset parameter must not be empty", func() { RandomString(100, []rune{}) }) - is.PanicsWithValue("lo.RandomString: Size parameter must be greater than 0", func() { RandomString(0, LowerCaseLettersCharset) }) + is.PanicsWithValue("lo.RandomString: charset must not be empty", func() { RandomString(100, []rune{}) }) + is.PanicsWithValue("lo.RandomString: size must be greater than 0", func() { RandomString(0, LowerCaseLettersCharset) }) } func TestChunkString(t *testing.T) { @@ -53,7 +53,7 @@ func TestChunkString(t *testing.T) { result6 := ChunkString("明1好休2林森", 2) is.Equal([]string{"明1", "好休", "2林", "森"}, result6) - is.Panics(func() { + is.PanicsWithValue("lo.ChunkString: size must be greater than 0", func() { ChunkString("12345", 0) }) }