The first one is converting a constant, the other one a variable. The are different rules when converting contants. https://golang.org/ref/spec#Conversions **Constants:** `int(1.2) // illegal: 1.2 cannot be represented as an int` **Non-Constant:** x can be converted to type T if `x's type and T are both integer or floating point types.`
– mkoprivaSep 11 '19 at 10:13
6
See related / possible duplicate: [Does Go compiler's evaluation differ for constant expression and other expression](https://stackoverflow.com/questions/39444852/does-go-compilers-evaluation-differ-for-constant-expression-and-other-expressio/39445372#39445372)
– iczaSep 11 '19 at 10:15
2
Possible duplicate of [GO lang - constant truncated to integer](https://stackoverflow.com/questions/16151199/go-lang-constant-truncated-to-integer)
– Shudipta SharmaSep 11 '19 at 10:58