● 定義は定数, コンパイル時に値が決まる Definition is constant, value determined at compile time. ● ConstDecl中のConstSpecのindex値が入る The index value of ConstSpec in ConstDecl is entered.
「数値に意味がある」定数 Constants with meaningful numerical values e.g. ・Exit Code ・DBに定義された値 Value defined in DB コードの差分に数値の変更が表れないため意図しない数値の変更に 気付きにくい Difficult to notice unintended numerical changes because numerical changes are not represented in the code differences. Iotaを使わない方が良い場面 Situations where iota should not be used.
● iotaはGoの連番定数生成の仕組み iota is Go's sequential constant generation mechanism ● iotaはconst宣言のindex値として扱われる iota is treated as an index value of const declaration ● iota + 1でゼロ値による意図しない挙動を防げる `iota +1` to prevent unintended behavior due to zero values. ● 1 << iotaで単一の値で複雑な状態も表現できる Complex states can be represented with a single value in `1 << iota`