From c29691cf8c31ed750fa5dc920c5b5ebdbaf7a1dd Mon Sep 17 00:00:00 2001 From: Ozaryx Date: Thu, 2 Feb 2023 18:19:02 +0700 Subject: [PATCH] Update README.md In Go global and local variables and constants exists --- README.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b7c9cc0..21607ff 100644 --- a/README.md +++ b/README.md @@ -288,12 +288,22 @@ const qux = 'qux' #### Go -(variables are block scoped in Go) - ```go package main +// Global variables +// explicit +var foo string = "foo" + +// type inferred +var bar = "foo" + +// Global constant +// constant +const qux = "qux" + func main() { + // Local variables // explicit var foo string = "foo" @@ -303,7 +313,7 @@ func main() { // shorthand baz := "bar" - // constant + // Local constant const qux = "qux" } ```