Golang variables: Difference between revisions
From wikinotes
No edit summary |
|||
Line 17: | Line 17: | ||
<blockquote> | <blockquote> | ||
<syntaxhighlight lang="go"> | <syntaxhighlight lang="go"> | ||
float32(123) // cast int as float32 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Type Conversion --> | </blockquote><!-- Type Conversion --> |
Revision as of 13:18, 29 May 2022
Assignment
// declare and assign variable var name string name = "foo" // declare and assign var in one step var name string = "foo" // declare and assign variable, inferring type name := "foo"
Type Conversion
float32(123) // cast int as float32