https://github.com/godeltech/learninganddevelopment.generics-in-go
https://github.com/godeltech/learninganddevelopment.generics-in-go
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/godeltech/learninganddevelopment.generics-in-go
- Owner: GodelTech
- Created: 2022-01-27T11:09:23.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-01-27T11:11:30.000Z (over 4 years ago)
- Last Synced: 2024-12-26T18:19:05.395Z (over 1 year ago)
- Language: Go
- Size: 2.93 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# About
In the repository we have a few examples of *generics* usage in Go language.
All those examples had been written and verified using Go1.18 beta1.
Below, under the "Project Structure" section you could read details about each example.
More information regarding Generics in Golang you can find in the Godel blog.
# Project Structure
- cmd/comparable
shows how to use *comparable* constraint in generic functions;
- cmd/concat
shows how to use an interface as a constraint in generic functions;
- cmd/filter
shows how to use *any* in generic functions and how to use generics in your code at all;
- cmd/sum
shows how to use *union types* in your custom interfaces;
- cmd/zeros
an example of what's happening with *empty values* when you use generic functions.
# How to Run
Just like any other CLI Go application:
```shell
go run cmd/{APP_NAME_HERE}/main.go
```
for example:
```shell
go run cmd/comparable/main.go
```