Skip to content

Instantly share code, notes, and snippets.

View pomkine's full-sized avatar

Alexandr Afanasiev pomkine

  • Tabby
  • Kaş, Türkiye
View GitHub Profile
@pomkine
pomkine / process_csv.go
Created July 9, 2020 08:24
Node-like csv channeled read
func processCSV(rc io.Reader) (ch chan []string) {
ch = make(chan []string, 10)
go func() {
r := csv.NewReader(rc)
if _, err := r.Read(); err != nil { //read header
log.Fatal(err)
}
defer close(ch)
for {
rec, err := r.Read()
@pomkine
pomkine / options.go
Last active April 1, 2020 07:27
Go functional options
type Server struct {
addr string
timeout int
retry int
speed int
}
func NewServer(addr string, opts ...func(*Server)) (*Server, error) {
srv := new(Server)
srv.addr = addr
@pomkine
pomkine / mux.go
Created April 1, 2020 07:01
Using Go first class functions with channels
import (
"io"
"net"
)
type Mux struct {
ops chan func(map[net.Addr]net.Conn)
}
func (m *Mux) Add(conn net.Conn) {

Keybase proof

I hereby claim:

  • I am pomkine on github.
  • I am pomkine (https://keybase.io/pomkine) on keybase.
  • I have a public key whose fingerprint is DE8A E80B 9E0A A9A3 8F29 0DA3 980E 73BA 299B 9F27

To claim this, I am signing this object: