Skip to content

Commit

Permalink
panic on nil pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdata committed Nov 20, 2024
1 parent 1fd8a34 commit 05006db
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 8 deletions.
3 changes: 0 additions & 3 deletions stringer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ type stringizer[T any] struct {
}

func (s stringizer[T]) String() string {
if s.v == nil {
return "<nil>"
}
return fmt.Sprint(*s.v)
}

Expand Down
5 changes: 0 additions & 5 deletions stringer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ import (
)

func TestStringer(t *testing.T) {
var x *int
if s := Stringer(x).String(); s != "<nil>" {
t.Error(s)
}

txt := "text"
if s := Stringer(&txt).String(); s != "text" {
t.Error(s)
Expand Down

0 comments on commit 05006db

Please sign in to comment.