1
00:00:00,930 --> 00:00:06,870
So let's begin with a gentle introduction to the go programming language, and this might be a refresher

2
00:00:06,870 --> 00:00:11,990
for somebody that's worked in go a little bit but needs to kind of refresh their memory.

3
00:00:12,030 --> 00:00:17,310
It might be an introduction to this language for people that are familiar with other languages.

4
00:00:17,550 --> 00:00:21,220
Or it might be the very first time you've ever written a program of any sort.

5
00:00:21,240 --> 00:00:22,280
It doesn't matter.

6
00:00:22,320 --> 00:00:28,950
We're going to go through a series of brief lectures that give us just enough information to begin to

7
00:00:28,950 --> 00:00:31,130
start with Web applications.

8
00:00:31,140 --> 00:00:34,690
So you're going to learn the very basics and go and it's not that hard.

9
00:00:35,220 --> 00:00:40,800
So I'm using visual studio code, which I still don't like and may never like, but I'm going to force

10
00:00:40,800 --> 00:00:45,810
myself to use it for this portion of the course so that I at least know enough to give people a hand

11
00:00:45,810 --> 00:00:47,240
if they run into difficulties.

12
00:00:47,760 --> 00:00:53,390
So I start by starting up visual studio code, which I've done, and I have an empty project.

13
00:00:53,400 --> 00:00:58,200
So if I come in to hear the Explorer and click on that, it says you have not yet open the folder.

14
00:00:58,200 --> 00:00:59,160
So it's open a folder.

15
00:00:59,550 --> 00:01:00,870
I'm going to create a new folder.

16
00:01:00,900 --> 00:01:02,160
It doesn't matter where I create it.

17
00:01:03,000 --> 00:01:09,000
Learning go, but remember where you create it in case you need to go find the files, create and then

18
00:01:09,000 --> 00:01:10,040
I'll go into that folder.

19
00:01:11,390 --> 00:01:11,870
Open.

20
00:01:13,450 --> 00:01:18,280
And in here, I'm going to create an empty file of first of all, I'll get rid of this welcome screen

21
00:01:18,850 --> 00:01:23,590
and then I will create a new file by rolling over the Explorer and hitting this little icon that says

22
00:01:23,590 --> 00:01:24,040
new file.

23
00:01:24,730 --> 00:01:25,900
And I'll call this file.

24
00:01:25,920 --> 00:01:30,280
I mean, I'll go and every go file has to end with Dutko.

25
00:01:30,280 --> 00:01:31,650
It has to have that extension.

26
00:01:31,990 --> 00:01:32,780
So I create it.

27
00:01:34,300 --> 00:01:36,670
Now I have an empty file name Mango.

28
00:01:36,940 --> 00:01:43,840
And as is the case with all go files, the very first thing that must appear to go file is a declaration

29
00:01:43,840 --> 00:01:46,080
that says, what package do you belong to?

30
00:01:46,180 --> 00:01:48,670
And the keyword to make that happen is simply package.

31
00:01:49,640 --> 00:01:54,800
And it is a convention, I can call this Treva if I wanted to, but it is a convention that your main

32
00:01:54,800 --> 00:01:56,000
package is called name.

33
00:01:56,390 --> 00:01:57,620
So I'm going to call my mink's.

34
00:01:57,620 --> 00:02:01,920
I like to adhere to good standards and write what is known as idiomatic go.

35
00:02:02,840 --> 00:02:03,250
All right.

36
00:02:03,260 --> 00:02:07,480
So I've declared this main package and I declare my package is being made.

37
00:02:08,150 --> 00:02:12,440
Every main package must consist of at least one function.

38
00:02:12,830 --> 00:02:15,710
And if you don't know what a function is, don't worry, you're going to find out shortly.

39
00:02:16,340 --> 00:02:19,070
And that function must be called main.

40
00:02:19,520 --> 00:02:19,990
All right.

41
00:02:20,000 --> 00:02:20,730
So I can do that.

42
00:02:20,870 --> 00:02:23,000
How do you declare a function and go with the keyword?

43
00:02:23,180 --> 00:02:26,120
OK, and this one has to be called main.

44
00:02:26,540 --> 00:02:33,260
And because it's a function, it has to have parentheses and a function body begins and ends with curly

45
00:02:33,530 --> 00:02:34,000
braces.

46
00:02:34,520 --> 00:02:36,290
So what are these parentheses for?

47
00:02:36,320 --> 00:02:41,120
First of all, functions have to have parentheses because you need sometimes to pass information to

48
00:02:41,120 --> 00:02:42,910
a function which we're going to do momentarily.

49
00:02:43,280 --> 00:02:46,470
But the main function doesn't take any parameters at all.

50
00:02:47,030 --> 00:02:49,510
So technically speaking, this is a good program.

51
00:02:49,520 --> 00:02:51,440
It has a package named Main.

52
00:02:51,680 --> 00:02:56,360
It has a main package, in other words, and it has one function in there called Main, but it doesn't

53
00:02:56,360 --> 00:02:57,210
do anything yet.

54
00:02:57,620 --> 00:02:59,000
Well, I need to do something.

55
00:02:59,420 --> 00:03:00,590
What can I do?

56
00:03:00,620 --> 00:03:02,630
Well, let's let's think about functions for a minute.

57
00:03:02,630 --> 00:03:10,010
Maybe maybe I can create another function down here called func say say something.

58
00:03:11,360 --> 00:03:14,990
And that's going to take an argument because I need to know what to say.

59
00:03:15,290 --> 00:03:16,730
So I'm going to give it an argument.

60
00:03:16,730 --> 00:03:20,900
And the argument is going to be a string, just a word or a phrase or whatever it's going to be.

61
00:03:20,900 --> 00:03:23,570
It's going to be something stored a bunch of characters in a string.

62
00:03:24,320 --> 00:03:26,960
And because it's a string and string starts with the letter S..

63
00:03:26,960 --> 00:03:29,720
I'll give my variable the rather simple name of S.

64
00:03:30,280 --> 00:03:32,240
You think that might be enough, but it's not.

65
00:03:32,540 --> 00:03:38,240
I need to tell this function and the compiler what kind of parameter this is.

66
00:03:38,240 --> 00:03:39,760
What is is it a number?

67
00:03:39,770 --> 00:03:40,520
Is it a date.

68
00:03:40,550 --> 00:03:41,770
Is it a what.

69
00:03:41,780 --> 00:03:42,530
Is it a string.

70
00:03:42,560 --> 00:03:46,400
Well, in this case it is a string and string is one of the primitives built in to go.

71
00:03:47,300 --> 00:03:53,480
So I have a function name say something that takes one argument s which is a string and it's going to

72
00:03:53,480 --> 00:03:55,200
return some value.

73
00:03:55,250 --> 00:03:59,420
This is the great thing about functions, the little bits of code you can use over and over and over.

74
00:03:59,630 --> 00:04:04,220
You can call them from many places in your program or pretty much any place in your program and a lot

75
00:04:04,220 --> 00:04:04,730
of cases.

76
00:04:05,240 --> 00:04:10,450
And you can return some value so I can return a string.

77
00:04:10,910 --> 00:04:12,020
That's what I want to return.

78
00:04:12,050 --> 00:04:13,940
Now, this is going to be a really stupid function.

79
00:04:14,150 --> 00:04:17,810
All it's going to do is return whatever it's passed.

80
00:04:18,080 --> 00:04:20,220
And how do I return something from a function?

81
00:04:20,240 --> 00:04:24,470
Well, not surprisingly, the word to make that happen, the key word is return.

82
00:04:25,730 --> 00:04:31,010
And I only have one thing I can possibly return, which is a string s, so I haven't done anything else.

83
00:04:31,290 --> 00:04:31,730
All right.

84
00:04:31,730 --> 00:04:34,040
So now I've created a program that has two functions.

85
00:04:34,460 --> 00:04:39,430
The main function, which is the entry point for the application and func say something.

86
00:04:39,440 --> 00:04:40,280
Can I run this?

87
00:04:40,470 --> 00:04:41,230
Let's see what happens.

88
00:04:41,240 --> 00:04:42,050
So I save it.

89
00:04:42,320 --> 00:04:45,890
And you notice when I saved it, it applied formatting, which is rather thoughtful.

90
00:04:46,490 --> 00:04:47,600
How do I run this program?

91
00:04:47,600 --> 00:04:54,300
Go to terminal new terminal window and I'm going to simply write Go, run, maeng, go.

92
00:04:54,680 --> 00:04:55,460
So what should happen?

93
00:04:55,640 --> 00:04:57,940
Well, nothing actually should happen.

94
00:04:57,980 --> 00:04:58,500
Let's try it.

95
00:04:59,720 --> 00:05:00,490
Nothing happened.

96
00:05:00,560 --> 00:05:01,130
Why?

97
00:05:01,220 --> 00:05:02,450
I'm going to have this function.

98
00:05:03,140 --> 00:05:04,480
Surely something should take place.

99
00:05:04,490 --> 00:05:09,360
Well, I've never called this function so I can do that in my main function.

100
00:05:09,440 --> 00:05:13,340
This is the first bit of code that will get executed in the program.

101
00:05:13,340 --> 00:05:15,410
No matter how complex this program is.

102
00:05:15,680 --> 00:05:18,080
This main function is the entry point.

103
00:05:18,410 --> 00:05:20,360
So I can call that function.

104
00:05:20,360 --> 00:05:25,010
And I could do that just by saying say something and say something.

105
00:05:25,160 --> 00:05:28,540
If I just do it like that is going to say, oh, there's an error, you can't go any further.

106
00:05:28,580 --> 00:05:29,240
Why not?

107
00:05:29,690 --> 00:05:32,310
Because say something expects to receive a string.

108
00:05:32,330 --> 00:05:36,800
Well it's just puts a string in there and then go you can write a string by putting quotes around it.

109
00:05:37,700 --> 00:05:38,170
Hello.

110
00:05:39,050 --> 00:05:42,680
OK, I wanted to say hello now surely that's going to do something.

111
00:05:42,680 --> 00:05:48,560
So I've saved my code and I come down here and I'll clear the screen by hitting control and I'll run

112
00:05:48,560 --> 00:05:48,680
it.

113
00:05:49,930 --> 00:05:56,080
Well, nothing happened well, nothing happened because I called the function say something which returns

114
00:05:56,080 --> 00:05:59,020
a type of string, and I didn't do anything with that string.

115
00:05:59,020 --> 00:06:00,520
I need to store it somewhere.

116
00:06:00,640 --> 00:06:03,970
I need someplace to hold that value, whatever it returns back.

117
00:06:04,180 --> 00:06:05,320
And I do that with a variable.

118
00:06:06,010 --> 00:06:09,850
So let's create our first variable and we're going to create a variable two different ways.

119
00:06:09,850 --> 00:06:13,150
But this is the first way we're going to do it with the keyword VA.

120
00:06:13,870 --> 00:06:17,260
VA is a variable and the variable has to have a name.

121
00:06:17,830 --> 00:06:20,320
And I'll call this what to say.

122
00:06:20,320 --> 00:06:21,940
Variables can't have spaces in there.

123
00:06:21,940 --> 00:06:23,080
They can't start with the number.

124
00:06:23,290 --> 00:06:25,090
Pretty much anything else is good to go.

125
00:06:25,090 --> 00:06:30,340
But the approach that I'm using here, which is to start with a lowercase letter and then capitalize

126
00:06:30,340 --> 00:06:32,860
all the other ones cavalcades, that's the convention.

127
00:06:32,860 --> 00:06:36,040
In some case, you're going to want to start with a capital letter, but we'll get to that when we get

128
00:06:36,040 --> 00:06:36,300
to that.

129
00:06:36,310 --> 00:06:42,400
Right now, I've got a variable what to say and it still has an error y because as I said a while ago,

130
00:06:42,580 --> 00:06:45,970
go is a strictly typed or strongly typed language.

131
00:06:45,970 --> 00:06:46,820
It has to have a type.

132
00:06:47,170 --> 00:06:50,020
I'll give this the type string, which is the only type we know about right now.

133
00:06:50,860 --> 00:06:51,730
So perfect.

134
00:06:51,910 --> 00:06:54,880
I've created a variable, but I haven't done anything with it.

135
00:06:54,880 --> 00:06:59,080
And Visual Studio Code has helpfully reminded me that this is a problem.

136
00:06:59,080 --> 00:06:59,800
I have an error.

137
00:06:59,950 --> 00:07:04,870
So I see Red underline over here and over here on the right hand side, I see a little red thing in

138
00:07:04,870 --> 00:07:07,450
the bar that says there's an error in your code right there.

139
00:07:07,690 --> 00:07:08,440
Well, what is there?

140
00:07:08,470 --> 00:07:12,910
I can roll the mouse over it and it will tell me what to say declared but not used.

141
00:07:13,030 --> 00:07:15,430
And this is one of the nice features of go.

142
00:07:16,660 --> 00:07:19,510
If you create a variable, you have to use it.

143
00:07:19,840 --> 00:07:24,610
Otherwise the program will refuse to compile and that is a good thing.

144
00:07:24,610 --> 00:07:30,370
You do not want unused variables floating around your code base doing absolutely nothing, just cluttering

145
00:07:30,370 --> 00:07:31,480
it and taking up space.

146
00:07:31,780 --> 00:07:33,480
So I need to use this variable.

147
00:07:33,490 --> 00:07:38,350
Well, I was a minute ago, I said I need somewhere to hold the value returned by this function.

148
00:07:38,530 --> 00:07:40,150
This is the perfect place to use it.

149
00:07:40,600 --> 00:07:44,680
What to say is equal to say something.

150
00:07:45,270 --> 00:07:46,540
Well, how come I still have an error?

151
00:07:47,230 --> 00:07:52,210
Because even though I've created this variable, initialized it when I created using the keyword, it's

152
00:07:52,210 --> 00:07:53,650
just created as an empty string.

153
00:07:53,650 --> 00:07:54,970
There's nothing in there.

154
00:07:55,000 --> 00:07:57,340
It's a type string, but it has no characters in there.

155
00:07:58,090 --> 00:08:02,800
And even though I stored a value in it here, I still haven't done anything with that variable.

156
00:08:02,800 --> 00:08:03,850
I need to do something.

157
00:08:03,850 --> 00:08:04,660
So what am I going to do?

158
00:08:04,780 --> 00:08:06,670
I'm simply going to print it to the terminal.

159
00:08:07,330 --> 00:08:08,590
How am I going to do that?

160
00:08:08,620 --> 00:08:13,330
Well, there's a number of ways of doing it in the little hollow world example we had early on in the

161
00:08:13,330 --> 00:08:16,600
course we use the FMT print line function.

162
00:08:16,630 --> 00:08:20,380
This time we're going to use a different package that does pretty much the same thing for our purposes

163
00:08:20,380 --> 00:08:20,680
today.

164
00:08:20,680 --> 00:08:25,900
Anyway, I'm going to use the log package log, which is a reserved word so I can't have a variable

165
00:08:25,900 --> 00:08:27,340
name variable named Log.

166
00:08:27,640 --> 00:08:34,330
It is a package and if I hit DOT Visual Studio Code says, hey, you're using the package log, it has

167
00:08:34,330 --> 00:08:35,470
all these functions.

168
00:08:35,470 --> 00:08:36,630
Which ones do you want?

169
00:08:36,650 --> 00:08:42,430
Well, I'm going to use print line Priam TLM and log print line is a function.

170
00:08:42,460 --> 00:08:46,600
Therefore it must have parentheses and it expects but does not require.

171
00:08:46,600 --> 00:08:52,240
In this case, it expects something to be in between those parentheses, the values that I'm passing

172
00:08:52,240 --> 00:08:58,030
to that particular function print line and what I want to pass it is what to say.

173
00:08:59,500 --> 00:09:00,610
And if I say this.

174
00:09:03,210 --> 00:09:08,990
But if I save it after I give the variable to correct and save it, life is good.

175
00:09:09,060 --> 00:09:11,290
Now, I should be able to run this program.

176
00:09:11,310 --> 00:09:13,050
So when I come down here, I saved it.

177
00:09:13,290 --> 00:09:13,800
We're good.

178
00:09:13,980 --> 00:09:19,890
When I come down here and clear the screen and say, go, run, man, go look at what's going to happen.

179
00:09:19,890 --> 00:09:23,040
First of all, it's going to say package means so great.

180
00:09:23,040 --> 00:09:23,850
We're the main package.

181
00:09:23,850 --> 00:09:25,280
That's the one that has to run first.

182
00:09:25,290 --> 00:09:30,660
This is my entry point and we're going to use the funk machine, which is the absolute entry point.

183
00:09:31,050 --> 00:09:33,480
But where did this come from, this import log?

184
00:09:33,780 --> 00:09:41,100
Well, when I imported when I use the package log, I need to tell my program that I'm using that package.

185
00:09:41,100 --> 00:09:42,180
I need to import it.

186
00:09:42,180 --> 00:09:46,290
And once I import it, I have access to all of the functions that are built into that package.

187
00:09:46,290 --> 00:09:49,120
And as we saw a minute ago, we can look again logged.

188
00:09:49,350 --> 00:09:52,200
All of these functions are part of that package.

189
00:09:52,530 --> 00:09:53,490
Therefore, I can use them.

190
00:09:53,620 --> 00:09:55,290
So some are some are other things.

191
00:09:55,290 --> 00:09:57,000
But we they're all available to us.

192
00:09:57,090 --> 00:09:59,020
If I don't import it, I can't use it.

193
00:09:59,730 --> 00:10:06,360
So this idea, like every good idea out there, integrated development environment, when you use a

194
00:10:06,360 --> 00:10:07,980
package, it does the imports for you.

195
00:10:08,070 --> 00:10:12,810
If it's not working for you or you're just using a text editor or whatever you need, you need to manually

196
00:10:12,810 --> 00:10:14,250
type in import log.

197
00:10:14,610 --> 00:10:17,280
But we're using visual studio code, so life is good.

198
00:10:17,760 --> 00:10:18,840
So I go to run this.

199
00:10:18,840 --> 00:10:20,460
It'll say, where's the main package?

200
00:10:20,460 --> 00:10:21,120
Here it is.

201
00:10:21,120 --> 00:10:22,140
Where's the main function?

202
00:10:22,140 --> 00:10:22,800
Here it is.

203
00:10:22,800 --> 00:10:23,910
What do you want me to do?

204
00:10:24,060 --> 00:10:25,620
First of all, you're declaring a variable.

205
00:10:25,620 --> 00:10:26,100
Perfect.

206
00:10:26,100 --> 00:10:27,060
I've created a variable.

207
00:10:27,060 --> 00:10:35,070
It has an empty string now in I want you to store into what to say this variable, whatever the function,

208
00:10:35,070 --> 00:10:39,450
say something returns so I can say it calls it.

209
00:10:39,450 --> 00:10:40,080
I passed it.

210
00:10:40,080 --> 00:10:40,560
Hello.

211
00:10:40,590 --> 00:10:41,310
Say something.

212
00:10:41,310 --> 00:10:41,970
What do I do with it?

213
00:10:41,970 --> 00:10:43,380
I just return whatever you pass me.

214
00:10:43,770 --> 00:10:48,630
So I'm storing this value in this variable and now I'm printing it out.

215
00:10:48,960 --> 00:10:49,530
Very good.

216
00:10:50,150 --> 00:10:53,040
I can use that function again and I can do it this way.

217
00:10:53,280 --> 00:10:59,640
I can say declare another string variable var say something else.

218
00:11:02,040 --> 00:11:12,090
And it's also a string of other spills, something right, and then I can just say down here, say something

219
00:11:12,090 --> 00:11:17,100
else is a sign, the value of say something and I'll pass it goodbye.

220
00:11:19,620 --> 00:11:25,050
And then I will print that to the terminal because I can't declare this variable even if I store something

221
00:11:25,050 --> 00:11:27,070
in it, unless I do something with it.

222
00:11:27,480 --> 00:11:29,820
So log line.

223
00:11:32,120 --> 00:11:37,790
Say are something else, some.

224
00:11:38,150 --> 00:11:38,860
What am I doing here?

225
00:11:39,780 --> 00:11:44,460
Loved up front line, say something else.

226
00:11:45,810 --> 00:11:52,020
All right, now I want to run it, even though I'm calling the same function, say something, I'm passing

227
00:11:52,020 --> 00:11:52,890
at a different parameter.

228
00:11:52,890 --> 00:11:58,470
So I should, first of all, call the function, get the word hello, print it out, call the function

229
00:11:58,470 --> 00:12:01,530
again, store the variable somewhere else and print that out.

230
00:12:01,920 --> 00:12:02,790
Let's see if it works.

231
00:12:04,290 --> 00:12:11,610
Hello, goodbye, and I can even do it this way, logged print line without a variable print line,

232
00:12:11,950 --> 00:12:19,770
say something finally, it doesn't matter what I put in there, so I save that.

233
00:12:19,860 --> 00:12:22,590
And now I'm passing a function as a parameter.

234
00:12:22,590 --> 00:12:25,950
I'm actually passing that call to this function as a parameter to log print line.

235
00:12:25,980 --> 00:12:26,560
Will that work?

236
00:12:27,720 --> 00:12:28,500
Yes, it does.

237
00:12:28,680 --> 00:12:29,220
Perfect.

238
00:12:29,820 --> 00:12:30,270
All right.

239
00:12:31,050 --> 00:12:34,440
Last thing I want to do, I want to talk about some different variable types.

240
00:12:34,440 --> 00:12:35,940
So I'm going to create another variable.

241
00:12:36,510 --> 00:12:42,420
I'm going to call this are because I want it to be not of type string, but of another primitive type

242
00:12:42,780 --> 00:12:45,740
it and it just holds whole numbers.

243
00:12:46,200 --> 00:12:49,940
So down here, after finally I will give a lecture.

244
00:12:50,010 --> 00:12:50,830
Let's not give it a value.

245
00:12:50,850 --> 00:12:52,850
Let's see what happens if we leave it on initialized.

246
00:12:52,860 --> 00:12:55,090
If I say log dot.

247
00:12:55,260 --> 00:12:55,950
Print line.

248
00:12:57,880 --> 00:13:00,200
I declared a variable.

249
00:13:00,490 --> 00:13:03,230
Now I'm using it, but at no point did I give it a value.

250
00:13:03,490 --> 00:13:04,600
What's it going to print out there?

251
00:13:05,560 --> 00:13:07,620
That's going to clear the screen.

252
00:13:09,700 --> 00:13:10,590
Run the program.

253
00:13:11,600 --> 00:13:17,730
And apparently the value of the type and if you don't give it a value, defaults to zero.

254
00:13:17,750 --> 00:13:18,830
That makes perfect sense.

255
00:13:19,070 --> 00:13:25,910
But if I give it a value here, I is equal to seven and save it and clear the screen and run the program

256
00:13:25,910 --> 00:13:26,210
again.

257
00:13:26,510 --> 00:13:27,670
Now I have seven.

258
00:13:27,890 --> 00:13:29,990
What if I give a different value?

259
00:13:30,000 --> 00:13:30,920
I equals eight.

260
00:13:31,580 --> 00:13:33,020
Well, it seems useless.

261
00:13:33,020 --> 00:13:37,970
I assigned the value of seven to I and I immediately assign the value of eight to what does it get.

262
00:13:38,330 --> 00:13:40,820
Go Roumain go perfect.

263
00:13:40,820 --> 00:13:41,540
It has eight.

264
00:13:42,440 --> 00:13:51,860
Last thing I want to talk about just for fun, ok is that functions can actually return more than one

265
00:13:51,860 --> 00:13:53,390
value and this is unusual.

266
00:13:53,390 --> 00:13:55,310
You don't see this in a lot of programming languages.

267
00:13:55,310 --> 00:13:56,270
Java doesn't have it.

268
00:13:56,780 --> 00:14:01,940
You can do the same thing in by returning an array but go it has first class functions.

269
00:14:01,940 --> 00:14:03,290
You can return more than one value.

270
00:14:03,300 --> 00:14:04,820
So let's change our function.

271
00:14:05,210 --> 00:14:08,650
It's going to return to strings, string string.

272
00:14:08,690 --> 00:14:13,460
Now, when you have more than one thing being returned, you need to wrap those in parentheses.

273
00:14:13,460 --> 00:14:13,820
That's it.

274
00:14:13,850 --> 00:14:15,680
So I want to return a string and a string.

275
00:14:16,040 --> 00:14:17,330
Now I immediately have an error.

276
00:14:17,330 --> 00:14:21,350
First of all, say something returns to values and you're only storing it in one.

277
00:14:21,350 --> 00:14:22,100
So that's bad.

278
00:14:22,760 --> 00:14:27,340
Here, say something is supposed to return to values, but you're only returning one, so that's bad.

279
00:14:27,350 --> 00:14:28,310
So we need to fix this.

280
00:14:28,640 --> 00:14:31,640
So we need to return another value.

281
00:14:32,090 --> 00:14:39,200
So let's just return hardcoded string world there they are gone.

282
00:14:39,440 --> 00:14:40,850
But up here I have two errors.

283
00:14:41,420 --> 00:14:48,310
How am I going to get the two values string string into a on this side of the parentheses?

284
00:14:48,320 --> 00:14:52,640
Well, as you might expect, the very first thing I'm returning is whatever was passed to me.

285
00:14:52,640 --> 00:14:57,710
The second thing is the key word is the is the word world, which is just a string.

286
00:14:57,710 --> 00:14:59,420
So I need somewhere to store that.

287
00:14:59,780 --> 00:15:01,040
Well, I can do it like this.

288
00:15:01,400 --> 00:15:03,200
VAR world string.

289
00:15:04,220 --> 00:15:09,500
OK, and then here I could say I want you to take the second return value and staut and world.

290
00:15:10,400 --> 00:15:12,650
OK, that works world.

291
00:15:13,590 --> 00:15:14,910
Rule declared safe.

292
00:15:15,630 --> 00:15:16,290
So that's gone.

293
00:15:16,320 --> 00:15:20,520
I'm still not using it and here where I call the function again world.

294
00:15:23,590 --> 00:15:29,250
Save and down here when I don't need to do anything because I'm not doing anything with the return values,

295
00:15:29,260 --> 00:15:31,180
but it says you're still not using the word world.

296
00:15:31,220 --> 00:15:32,500
Well, I don't want that.

297
00:15:32,530 --> 00:15:35,470
That's a totally unnecessary second parameter.

298
00:15:35,740 --> 00:15:39,130
And I put it in there purely for illustrative purposes.

299
00:15:39,340 --> 00:15:41,860
I actually don't even want to use the word world.

300
00:15:41,890 --> 00:15:43,870
It's just a complete waste of time.

301
00:15:44,110 --> 00:15:49,600
What I can do instead of storing the value is just tell the compiler, ignore the second return parameter.

302
00:15:49,600 --> 00:15:51,730
And that's what the underscore character means.

303
00:15:52,120 --> 00:15:54,220
Ignore the second return parameter.

304
00:15:54,250 --> 00:15:55,540
That's what the underscore means.

305
00:15:55,870 --> 00:16:02,680
And now I should be able to, once I save this, come down here, clear the screen and run the program.

306
00:16:02,920 --> 00:16:03,820
And it should work.

307
00:16:03,820 --> 00:16:04,740
And it does.

308
00:16:05,110 --> 00:16:05,610
All right.

309
00:16:06,580 --> 00:16:13,330
So you might notice that go is rather rather strict other programming languages like P, P or not.

310
00:16:13,340 --> 00:16:14,770
And I'll give you an example of that.

311
00:16:14,770 --> 00:16:20,630
So I have running in an idea over here and I've created a new empty file, which I called maned up.

312
00:16:21,280 --> 00:16:24,010
And if you don't know or don't care about it, just ignore this.

313
00:16:24,460 --> 00:16:27,760
But all files have to start with that little token.

314
00:16:29,200 --> 00:16:35,200
With a question mark on the pointy bracket and variables and start with the dollar sign for reasons

315
00:16:35,200 --> 00:16:41,650
I'll never understand, but they do so I can call this s four string is given the value of hello.

316
00:16:42,760 --> 00:16:43,500
That's no problem.

317
00:16:43,510 --> 00:16:43,990
It works.

318
00:16:43,990 --> 00:16:48,260
And then I'm down here, I can say Echo Dollar Sign s to print that to the screen.

319
00:16:48,280 --> 00:16:58,630
So now when I run this run maned not run meaned up, it runs prints out the word hello perfect.

320
00:16:58,930 --> 00:17:01,920
But I can now do this dollar sign as is equal to seven.

321
00:17:01,990 --> 00:17:05,380
I can store an intern there and the program will run just fine.

322
00:17:05,410 --> 00:17:05,950
No problem.

323
00:17:05,950 --> 00:17:09,160
It prints out seven and I can to create and create another variable.

324
00:17:09,520 --> 00:17:16,780
VAR two is given the value of zero and even though I'm not using it, we will run.

325
00:17:16,780 --> 00:17:23,440
And there's a reason for that is an interpreted language, which means any time you run a file on the

326
00:17:23,440 --> 00:17:25,960
same is true of Python, for example, or JavaScript.

327
00:17:26,200 --> 00:17:31,950
It has to be run through an interpreter and an interpreter takes that file, loads it from disk, loads

328
00:17:31,960 --> 00:17:37,720
it into memory, passes through it, runs it through the interpreter, produces machine code and then

329
00:17:37,720 --> 00:17:44,260
executes the instructions, which means by default, interpreting languages are pretty slow, in contrast.

330
00:17:45,790 --> 00:17:52,990
Go is a strongly typed, compiled language, which means we don't actually ever serve or do anything

331
00:17:52,990 --> 00:17:58,480
with mango, all of our go files and by the time we're done, this course will have many go files in

332
00:17:58,480 --> 00:17:59,260
different packages.

333
00:17:59,260 --> 00:18:03,970
Even they're compiled into a single program, a binary.

334
00:18:04,180 --> 00:18:07,960
And that binary is executed and it is much, much faster.

335
00:18:07,960 --> 00:18:13,600
And because it's compiled, go has the ability to say, well, you're not using that that variable.

336
00:18:13,600 --> 00:18:14,740
I'm not going to let you do that.

337
00:18:15,130 --> 00:18:18,730
In contrast, over IP, we can do this.

338
00:18:18,730 --> 00:18:22,360
We can have variables that change type because it's not strongly typed.

339
00:18:22,630 --> 00:18:28,150
We can also have variables that are never used because we need to load it into disk and execute it through

340
00:18:28,150 --> 00:18:30,730
the interpreter before we can actually do anything with it.

341
00:18:30,820 --> 00:18:38,110
So it's possible to have sloppy code go more or less forces you to be concise and only to include things

342
00:18:38,110 --> 00:18:39,370
you're actually using.

343
00:18:40,000 --> 00:18:45,250
So the other advantage, of course, is a compiled language is much, much faster than an interpreted

344
00:18:45,250 --> 00:18:45,640
language.

345
00:18:45,640 --> 00:18:52,720
Go is, on average, more than two hundred times faster than a similar function executed in say so it

346
00:18:52,720 --> 00:18:57,430
has that going for and it forces me to keep my code clean, which makes me rather happy.

347
00:18:57,910 --> 00:18:58,210
All right.

348
00:18:58,210 --> 00:18:59,500
That's enough for this time around.

349
00:18:59,500 --> 00:19:04,570
In the next lecture, we will begin to look at structure and types in defining our own variable types.

350
00:19:05,320 --> 00:19:07,690
And we'll also look at a few more primitives along the way.

351
00:19:07,700 --> 00:19:10,870
So far, we've only seen string and we also have time.

352
00:19:11,080 --> 00:19:14,080
The time type, we have float's.

353
00:19:14,080 --> 00:19:15,010
We have other primitives.

354
00:19:15,010 --> 00:19:18,640
You should be familiar with those and you will be by the time we get through this little introduction

355
00:19:19,090 --> 00:19:19,700
refresher.

356
00:19:20,050 --> 00:19:21,100
See you in the next lecture.
