<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/mocking-your-way-into-go-generics-parjvveev" -->

---
title: Mocking your Way into Go Generics | daily.dev
description: Pegomock supports Go Generics in its new release. Before generics, we had to generate matchers for custom types, and would generate lots of functions like. To...
canonical: https://daily.dev/posts/mocking-your-way-into-go-generics-parjvveev
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Mocking your Way into Go Generics | daily.dev
og:description: Pegomock supports Go Generics in its new release. Before generics, we had to generate matchers for custom types, and would generate lots of functions like. To...
og:url: https://daily.dev/posts/mocking-your-way-into-go-generics-parjvveev
og:image: https://api.daily.dev/og/posts/PaRjvvEEV.png
og:image:alt: Mocking your Way into Go Generics
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Mocking your Way into Go Generics

**[Medium](https://daily.dev/sources/medium_js)** · 2 min read · 10 upvotes · 0 comments

## Summary

Pegomock supports Go Generics in its new release. Before generics, we had to generate matchers for custom types, and would generate lots of functions like. To generate a mock, in a terminal we can now run: This will give us a new struct type and a function.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/@peter.gtz/mocking-your-way-into-go-generics-fdf8c2a41a18?source=rss------golang-5>

---

Tags: [#testing](https://daily.dev/tags/testing), [#golang](https://daily.dev/tags/golang)

[View this post on daily.dev](https://daily.dev/posts/mocking-your-way-into-go-generics-parjvveev)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Mocking your Way into Go Generics","url":"https://daily.dev/posts/mocking-your-way-into-go-generics-parjvveev","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/mocking-your-way-into-go-generics-parjvveev"},"datePublished":"2023-05-11T16:27:03.302Z","dateModified":"2023-05-11T16:27:03.124Z","description":"Pegomock supports Go Generics in its new release. Before generics, we had to generate matchers for custom types, and would generate lots of functions like. To...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/85a331d5534bcd6ad7888d558248c7df?_a=AQADKdt","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/85a331d5534bcd6ad7888d558248c7df?_a=AQADKdt","isAccessibleForFree":true,"articleSection":"Medium","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Medium","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/medium","url":"https://daily.dev/sources/medium_js"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/mocking-your-way-into-go-generics-parjvveev","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":10},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"testing,golang","timeRequired":"PT2M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Medium","item":"https://daily.dev/sources/medium_js"},{"@type":"ListItem","position":3,"name":"Mocking your Way into Go Generics"}]}
```

