Skip to content

Instantly share code, notes, and snippets.

Avatar

Alexandr Afanasiev pomkine

View GitHub Profile
@pomkine
pomkine / process_csv.go
Created Jul 9, 2020
Node-like csv channeled read
View process_csv.go
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 Apr 1, 2020
Go functional options
View options.go
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 Apr 1, 2020
Using Go first class functions with channels
View mux.go
import (
"io"
"net"
)
type Mux struct {
ops chan func(map[net.Addr]net.Conn)
}
func (m *Mux) Add(conn net.Conn) {
View keybase.md

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:

You can’t perform that action at this time.