Title: Show HN: AssertGo – Fluent Assertion Library for Go

I like AssertJ-style fluent assertions. I tried to find a library that does that for Go, but couldn't. So I wrote my own some time ago, but I didn't quite like it. A few days ago I heard about Go 1.27 and the addition of generic methods, so I gave it another try.

I like the way it came out this time. Most of the code was written with 1.26. Just now, after the 1.27 RC release, I changed the top-level methods to be generic - previously they were `any`.

As for the AI: I used Claude Sonnet, but as a codegen more than anything else. All the design choices are mine, and everything is done in small, incremental commits.

https://github.com/sku0x20/assertgo

Some examples:

    T(t).Assert("hello").EqualTo("hello")
    T(t).AssertInt(10).GreaterThan(5)
    T(t).AssertSlice([]int{1, 2, 3}).ContainsAll([]int{1, 3})
    T(t).AssertMap(map[string]int{"a": 1}).HasLength(1)
    T(t).AssertType(42).Is[int]()

1 points | by duckydude20 1 hour ago

0 comments