We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6c65f2a commit 06eba1cCopy full SHA for 06eba1c
4_constants/constants.go
@@ -0,0 +1,27 @@
1
+package main
2
+
3
+import "fmt"
4
+//before function it can be declared
5
+//but := short hand cant be used outside function
6
+const age=30
7
+const word="go" //-whenever needed can be used in the program
8
9
+func main(){
10
+ const name string = "golang" //type can skippked it infers itself
11
12
+ //try to reassign the value its not allowed
13
+ //-name="js" ---not allowed
14
15
+ /*int*/
16
+ //const age=30
17
+ fmt.Println(age)
18
19
20
+ //--CONSTANT GROUPING--// (Whenever u need many constants)
21
+ const (
22
+ port=5000
23
+ host="localhost"
24
+ )
25
+ fmt.Println(port,host)
26
27
+}
0 commit comments