const base … const damp … const initialBias … const initialN … const skew … const tmax … const tmin … func punyError(s string) error { … } // decode decodes a string as specified in section 6.2. func decode(encoded string) (string, error) { … } // encode encodes a string as specified in section 6.3 and prepends prefix to // the result. // // The "while h < length(input)" line in the specification becomes "for // remaining != 0" in the Go code, because len(s) in Go is in bytes, not runes. func encode(prefix, s string) (string, error) { … } // madd computes a + (b * c), detecting overflow. func madd(a, b, c int32) (next int32, overflow bool) { … } func decodeDigit(x byte) (digit int32, ok bool) { … } func encodeDigit(digit int32) byte { … } // adapt is the bias adaptation function specified in section 6.1. func adapt(delta, numPoints int32, firstTime bool) int32 { … }