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
Panicking in a library is an anti-pattern in Go. It results in indeterministic and unpredictable code. The caller has no idea when a library is going to panic unless they are experts in the library's codebase.
I believe a better option would be to allow for any size in the New() function, but then checking it in the Build() and returning an error. This makes it more idiomatic and removes the possibility that the caller's program crashes unexpectedly because of a bad input.
The text was updated successfully, but these errors were encountered:
Panicking in a library is an anti-pattern in Go. It results in indeterministic and unpredictable code. The caller has no idea when a library is going to panic unless they are experts in the library's codebase.
Currently, this is being done in several places:
gcache/cache.go
Line 70 in bbe6d2a
gcache/cache.go
Line 163 in bbe6d2a
I believe a better option would be to allow for any size in the
New()
function, but then checking it in theBuild()
and returning an error. This makes it more idiomatic and removes the possibility that the caller's program crashes unexpectedly because of a bad input.The text was updated successfully, but these errors were encountered: