Trying Generics on Go through implementing Tiny Cache Client


The Go1.18 with Generics will come soon. So i’m going to try Generics.

We can use Generics in Go Playground by setting “go dev branch”.


You can use Generics by writing bracket and type.

(I’m wondering why generics syntax is bracket [T] instead of gt and lt<T>. )

Cache value is allowed all type by any.

Current Cache Client’s value is often interface{} , so we have to cast the cache value. However now you have a typed cache client!


Done! The following link is full code.

Next, i want to try declaring constraint by custom type or interface.





Love podcasts or audiobooks? Learn on the go with our new app.

Who is Speaking On Your Behalf?

AWS re:invent 2017 — Day 1

Gem in Ruby and Rails

Build a Voice Proxy With Cloud Functions

My Hack The North 2021 Experience


Machine Learning Model inside Docker

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
yamaguchi naoto

yamaguchi naoto

More from Medium

Golang + Svelte Application

[Golang] How To Use Message Broker In Golang

Nil Pointer Method Receivers In Go

SQL Injection with GO and Fix