News for hackers. Stuff that matters.
Re:Revisiting Interface Segregation in Go by the_gipsy on Friday November 07, 2025 @12:22PM (#45848652)
Is this pattern commonly used? Any drawbacks?

Sounds much better than the interface boilerplate if it's just for the sake of testing.

Re:Revisiting Interface Segregation in Go by jgdxno on Friday November 07, 2025 @01:18PM (#45849243)
At work we use it heavily. You don't really see "a zillion interfaces" after a while, only set of dependencies of a package which is easy to read, and easy to understand.

"makes it hard to cone up with good names" is not really a problem, if you have a `CreateRequest` method you name the interface `RequestCreator`. If you have a request CRUD interface, it's probably a `RequestRepository`.

The benefits outweigh the drawbacks 10 to one. The most rewarding thing about this pattern is how easy it is to split up large implementations, and _keep_ them small.

Re:Revisiting Interface Segregation in Go by durbatuluk on Friday November 07, 2025 @02:37PM (#45850142)
Any method you forget to overwrite from the embed struct gives a false "impression" you can call any method from mockS3. Most of time code inside test will be:

    // embedded S3Client not properly initialized
    mock := mockS3{}
    // somewhere inside the business logic
    s3.UploadReport(...) // surprise
Go is flexible, you can define a complete interface at producer and consumers still can use their own interface only with required methods if they want.