Skip to content

Instantly share code, notes, and snippets.

View jphsd's full-sized avatar
🏔️

jphsd

🏔️
View GitHub Profile
@jphsd
jphsd / interprocess.md
Last active October 13, 2024 16:46
Interprocess channels in Go by using named pipes

How to use channels across different processes in Go

A couple of code samples to show how a named pipe can be used to extend Go's channel paradigm for use between different processes running on a system.

  • interprocess1.go details a single byte channel.
  • interprocess2.go details a channel that passes slices of bytes.

Note that opening a write channel will return two channels -

@jphsd
jphsd / balance.go
Last active October 4, 2024 19:35
A recent interview question was to check a string for balanced brackets - here's my answer
package main
import "fmt"
/**
* Given a string expression, write a program to examine whether the pairs and the orders of
* "{", "}", "(", ")", "[", "]" are correct (all other chars are ignored). If they are correct, it is balanced.
* If balanced, just return "Balanced".
* If not balanced, return "Not Balanced: <problem-index>", where problem-index is the index of the first bracket
* that caused un-balancing.