Linear counter algorithm in Go