Golang variables: Difference between revisions

From wikinotes
No edit summary
Line 13: Line 13:
</syntaxhighlight>
</syntaxhighlight>
</blockquote><!-- Assignment -->
</blockquote><!-- Assignment -->
= Type Conversion =
<blockquote>
<syntaxhighlight lang="go">
string(123)  // casy int as string
</syntaxhighlight>
</blockquote><!-- Type Conversion -->

Revision as of 13:16, 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

string(123)  // casy int as string