type Node int
node, err := strconv.Atoi(num)
Foo(Node(node)) // Foo takes a Node, not an int
Is it possible to avoid the ugly “Node(node)” in the above example? Is there a more idiomatic way to force the compiler to consider node a Node and not an int?
Nothing really elegant. You could define an intermediate variable
or you could define a wrapper function
but I don’t think there are any one-line tricks. The way you are doing it seems fine. There is still a little stuttering here and there in Go.