Tabel driven tests in go are awesome. I like that they also allow you to run each sub-test separately with go test -run "TestFoo".
go test -run "TestFoo"
A small typo in the article: got != tt.want shouldn't compile as you can compare a slice to nil only.
got != tt.want
nil
Oh, you are right. DeepEqual can be used instead. I modified the code example.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Tabel driven tests in go are awesome. I like that they also allow you to run each sub-test separately with
go test -run "TestFoo"
.A small typo in the article:
got != tt.want
shouldn't compile as you can compare a slice tonil
only.Oh, you are right. DeepEqual can be used instead. I modified the code example.