Python version was translated to Go and some mistakes were corrected.