Skip to content

Instantly share code, notes, and snippets.


Burak Serdar bserdar

View GitHub Profile
bserdar /
Created Oct 22, 2018
More explicit error handling

This is a suggestion to make error handling more explicit than what's described in the official proposal.

An error handler is declared as:

handle err { return err }

This declares err as an error variable, and an err_handler as a

bserdar /
Last active Nov 22, 2018
Types are contracts


This started as a thought experiment after I read the Go generics and contracts proposal. The original proposal is powerful enough to specify precise type properties from the point of the generic implementor, however constraints such as "type T must support operator <" is over-specific in a language where < cannot be redefined. Such a constraints means "T must be numeric or string". So this exercise is an extension of the idea that contracts should be specified in terms of existing types, not in terms of type capabilities.

bserdar /
Created Oct 26, 2018
Java stream lookalike in Go
package main

import (

type Stream func() (int,bool)

func (s Stream) Filter(pred func(int) bool) Stream {