Skip to content

Instantly share code, notes, and snippets.

@teghnet
teghnet / state.go
Created October 30, 2023 11:33
State Machine for Charm
View state.go
// Package state is for implementing a simple state machine.
// In a [tea.Model.Update] method one can use a `case` for a [Transition] message to change the state.
//
// case state.Transition:
// if !msg.Used() {
// m.State = msg.State()
// return m, msg.AsUsed()
// }
package state
View generic-example.go
func must[t any](c t, err error) t {
if err != nil {
log.Fatalln(err)
}
return c
}
@teghnet
teghnet / main.go
Last active December 12, 2021 23:20
Homemade CLI Tools
View main.go
// This is an example for:
// https://www.tegh.net/2021/12/12/homemade-cli-tools/
package main
import (
"errors"
"fmt"
"io"
"log"
"os"
View keybase.md

Keybase proof

I hereby claim:

  • I am teghnet on github.
  • I am teghnet (https://keybase.io/teghnet) on keybase.
  • I have a public key ASANxWSZXtSxfHG2fNQoKyjGZTn3UswcyWGV4OtEbTo_ggo

To claim this, I am signing this object:

@teghnet
teghnet / main.go
Last active November 12, 2020 07:06
View main.go
package main
import (
"log"
"sync"
"time"
)
type SemaphoredWaitGroup struct {
sem chan bool
View Dockerfile
FROM bash
COPY test*.sh ./
RUN bash test_scenario.sh