A demo of using Go channels as a function composition technique.

Channels Example

This is a Go program containing functions that consume and produce channels. I think this is potentially a nicer API shape than e.g. filepath.WalkDir (running your function as a side-effect), bufio.Scanner (a special-purpose iterator), regexp.FindAll (appending to and then returning a potentially large slice), and so on. With this chan Value interface ‘hinge’ type, you can relatively easily compose unbounded producer/consumer functions.

The point of this toy project is to show what it would take for Go code to look (and more easily perform) a bit more like Unix shell/PowerShell pipelines. (Still nested function calls instead of a linear pipeline, but the generic composition aspect and the bounded memory consumption aspects are there.)

To me it seems like chan is the fundamental organizing principle of Go — Go ‘wants’ to be written this way, I sort of think? — and so there must be some reason I don’t understand that explains why the standard library is not written in a style similar to what I show here. (More generally, you’d want chan interface{}, or chan TaggedUnionThing, I suppose. And perhaps that is why it’s not standard. Still, it seems solveable...)

Similar Resources

Boilerplate for writing Go applications without framework using hexagonal application development approach

Boilerplate for writing Go applications without framework using hexagonal application development approach

Boilerplate for writing Go applications without framework using hexagonal application development approach

Dec 2, 2022

An e-book on building network applications using golang

Network programming with Go

Dec 7, 2021

Cook amazing genetic parts using our cookbook. Recipes and synthetic biology tools to take your breath away.

friendzymes-cookbook Friendly tools for a friendly community. A collection of tutorials and genetic tools for synthetic biology. This cookbook is a su

Aug 19, 2022

This is an example of a keep-it-simple directory layout for Go projects that was created using DDD principles, please copy and share if you like it.

DDD Go Template This project was created to illustrate a great architectural structure I developed together with @fabiorodrigues in the period I was w

Dec 5, 2022

Program that checks if the switch OLED is available on Nintendo using ChromeDP.

Nintendo Switch OLED stock checker Program that checks if the switch OLED is available on Nintendo using ChromeDP. It will check the pages for the Add

Nov 29, 2021

Check-location - A golang service to check user location using their IP address

this is a golang service to check user location using their IP address. The purp

Aug 29, 2022

M3U generator for Stirr, optimized for Channels' custom channels.

M3U generator for Stirr, optimized for Channels' custom channels.

Stirr for Channels This simple Docker image will generate an M3U playlist and EPG optimized for use in Channels and expose them over HTTP. Channels su

Oct 7, 2022

Book-API was made using Golang and PostgreSQL with technique CRUD with mux and pq

Book-API CRUD with PostgreSQL Table of contents 👀 General info Technologies Blog Setup General info BAPI or Book-API is a Golang REST API made to sho

Feb 18, 2022

FunctionStomping (using golang) : A new shellcode injection technique.

FunctionStomping (using golang) : A new shellcode injection technique.

goFunctionStomping FunctionStomping using golang Description This is a brand-new technique for shellcode injection to evade AVs and EDRs. This techniq

Oct 12, 2022

A lightweight operating system that allows Discord channels to essentially function as terminal interfaces

KuriOS KuriOS is an lightweight operating system that allows Discord channels to essentially function as terminal interfaces. As such, all permissions

Dec 31, 2021

Go implementation of the Heaven's Gate technique

Go implementation of the Heaven's Gate technique

gopherheaven is a Go implementation of the classic Heaven's Gate technique originally published by roy g biv on VX Heaven in 2009. gopherheaven can be used as an evasion technique to directly call 64-bit code from a 32-bit process.

Dec 20, 2022

Focus is a fully featured productivity timer for the command line, based on the Pomodoro Technique. Supports Linux, Windows, and macOS.

Focus is a fully featured productivity timer for the command line, based on the Pomodoro Technique. Supports Linux, Windows, and macOS.

Focus is a cross-platform productivity timer for the command line. It is based on the Pomodoro Technique, a time management method developed by Francesco Cirillo in the late 1980s.

Dec 26, 2022

A faster RWLock primitive in Go, 2-3 times faster than RWMutex. A Go implementation of concurrency control algorithm in paper Left-Right - A Concurrency Control Technique with Wait-Free Population Oblivious Reads

Go Left Right Concurrency A Go implementation of the left-right concurrency control algorithm in paper Left-Right - A Concurrency Control Technique w

Jan 6, 2023

ms - 'my story' creates a secure password string which can be memorized with a technique shared by Max.

On 23.12.21 20:22, Stefan Claas wrote: [...] Yes, I am aware of that, but how can one memorize a key when traveling and not taking any devices

Dec 24, 2021

Golang-demo - A repo for app golang-demo; bootstrapped by DevStream

golang-demo This is a repo for app golang-demo; bootstrapped by DevStream. By de

Mar 1, 2022

False-sharing-demo - Demo for performance effects of CPU cache false-sharing

Example of CPU cache false-sharing in Go. A simple example where 2 integer varia

Aug 28, 2022

Litestream-read-replica-demo - A demo application for running live read replication on fly.io with Litestream

Litestream Read Replica Demo A demo application for running live read replicatio

Oct 18, 2022

Go lang concurrency with channels and worker pools using sync.Pools.

Go Concurrency Go lang concurrency with channels and worker pools using sync.Pools. Concurrency Concurrency is an ability of a program to do multiple

Oct 31, 2021

Gogrok is a self hosted, easy to use alternative to ngrok. It uses SSH as a base protocol, using channels and existing functionality to tunnel requests to an endpoint.

gogrok A simple, easy to use ngrok alternative (self hosted!) The server and client can also be easily embedded into your applications, see the 'serve

Dec 3, 2022
Communication channels between Bitcoin users, agents, and services.

Channels Channels are a set of protocols designed to facilitate communication between users, agents, and services. Channels work on top of “peer chann

Dec 15, 2022
Practical concurrency guide in Go, communication by channels, patterns

Go Concurrency Guide This guide is built on top of the some examples of the book Go Concurrency in Go and Go Programming Language Race Condition and D

Dec 28, 2022
Repo Tugas Basic Programming Part 4(Complexity Analysis, Array, Slice, Function) ALTA Immersive BE5

Cara mengerjakan tugas hari ke 4 clone project ini dengan cara git clone https://github.com/ALTA-Immersive-BE5/Basic-Programming-Part4.git setelah cl

Dec 15, 2021
Repo Tugas Basic Programming Part 3(Array, Slice, Function) ALTA Immersive BE5

Cara mengerjakan tugas hari ke 3 clone project ini dengan cara git clone https://github.com/jackthepanda96/Basic-Programming-Part3.git setelah clone

Dec 15, 2021
Tugas Alta Immersive Backend Golang Basic Programming Part 4(Complexity Analysis, Array, Slice, Function)
Tugas Alta Immersive Backend Golang Basic Programming Part 4(Complexity Analysis, Array, Slice, Function)

Tatacara Melakukan Setup Tugas clone project ini dengan cara git clone https://github.com/Immersive-Backend-Resource/Basic-Programming-Part4.git sete

Jan 9, 2022
Tugas Alta Immersive Backend Golang Basic Programming Part 3(Array, Slice, Function)
Tugas Alta Immersive Backend Golang Basic Programming Part 3(Array, Slice, Function)

Tatacara Melakukan Setup Tugas clone project ini dengan cara git clone https://github.com/Immersive-Backend-Resource/Basic-Programming-Part3.git sete

Jan 9, 2022
A go blog demo by gin and gorm!

A go blog demo by gin and gorm!

Dec 7, 2022
Open IM Demo Register Use Tutorial

Open-IM-Demo-Register Use Tutorial First step: Log in to this site: https://www.aliyun.com/product/sms Buy Short Message Service You will get accessKe

Mar 19, 2022
roguelike tutorial in Go using the framework gruid

Gruid Go Roguelike Tutorial This tutorial follows the overall structure of the TCOD Python Tutorial, but makes use of the Go programming language and

Jul 25, 2022
This tutorial walks you through using the Cloud Functions minimal instances feature to mitigate cold starts.
This tutorial walks you through using the Cloud Functions minimal instances feature to mitigate cold starts.

Tutorial This tutorial walks you through using the Cloud Functions minimal instances feature to mitigate cold starts. Let’s take a deeper look at min

Jun 1, 2022