How many bits will be assigned to a const int?


This Content is from Stack Overflow. Question asked by Colandus

I am creating constants this way:

const (
    Separator_None = 0
    Separator_Dot  = 1
    Separator_Dash = 2

Will Golang create the constants as 8-bit integers or the default int 32/64?

If I want 8-bit integers, do I have to define it this way? I.e. Go won’t figure it out on its own and do it for me?

Separator_None int8 = 0
Separator_Dot       = 1
Separator_Dash      = 2


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?