Skip to content

Instantly share code, notes, and snippets.

View romsar's full-sized avatar

Roman Sarvarov romsar

View GitHub Profile
@romsar
romsar / scanner.go
Last active March 1, 2024 18:41
algo scan helper
// https://gist.github.com/romsar/6f11c51ec35a4a982eed786da958aecc
import (
"bufio"
"os"
"strconv"
"strings"
)
type Scanner struct {
s *bufio.Scanner
@romsar
romsar / graceful.go
Last active October 20, 2023 22:11
Graceful shutdown
package graceful
import (
"context"
"errors"
"log"
"strconv"
"time"
"golang.org/x/sync/errgroup"
@romsar
romsar / successjson.go
Last active October 11, 2022 15:48
Golang sucessJSON (slice modifier helper for tests using dot notation)
package successjson
func successJSON(body map[string]any) func(changes ...map[string]any) []byte {
return func(changes ...map[string]any) (bs []byte) {
defer func() {
if len(bs) == 0 {
bs = []byte("{}")
}
}()