'What is the meaning of following line of code in Golang?

var asciiSpace = [256]uint8{'\t': 1, '\n': 1, '\v': 1, '\f': 1, '\r': 1, ' ': 1}

how come we are allowed to have :1 in the code above and what is the meaning of that?

go


Solution 1:[1]

asciiSpace is declared an array of uint8 with indexes 0 .. 255 (i.e. the ASCII range), and the values for the indexed elements are set to 1.

The array indexes are given as '\t', '\n' etc. indicating they refer to whitespace characters.

My guess is you misinterpreted the sequence "index : value".

A similar example is given in a (randomly chosen) Go Tutorial.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 devio