1
00:00:01,020 --> 00:00:05,880
All right, before we can actually start writing any code, we need to get a development environment

2
00:00:05,880 --> 00:00:10,040
set up and I'm going to walk you through the steps necessary to make this happen.

3
00:00:10,410 --> 00:00:14,010
So the first thing we need to do is to get go and install it.

4
00:00:14,010 --> 00:00:16,020
And it is a really simple process.

5
00:00:16,020 --> 00:00:23,460
So I'm going to fire up a Web browser here and I'm going to go to this site, go langue.

6
00:00:23,580 --> 00:00:25,200
So go to go langue.

7
00:00:25,200 --> 00:00:28,650
And it doesn't matter if you're on Windows or a Mac or Linux.

8
00:00:28,650 --> 00:00:29,850
I happen to be on a Mac.

9
00:00:30,000 --> 00:00:31,680
The process is pretty much the same.

10
00:00:31,710 --> 00:00:34,550
So click on the big button that says download go.

11
00:00:34,590 --> 00:00:39,570
And I'm going to do that because I have an old version of Google installed and I'm on a Mac, so I'm

12
00:00:39,570 --> 00:00:41,400
going to choose Apple Mac OS.

13
00:00:41,400 --> 00:00:42,960
If you run Windows, choose Windows.

14
00:00:42,960 --> 00:00:44,460
If you're on Linux, choose Linux.

15
00:00:44,460 --> 00:00:48,680
If you're feeling really adventurous, I suppose you could install from source and compile it.

16
00:00:48,930 --> 00:00:51,660
I don't recommend that there's no benefit to doing it.

17
00:00:51,660 --> 00:00:55,980
So just click on the one appropriate for your operating system and download it.

18
00:00:56,370 --> 00:01:00,300
So I'm going to open have it open automatically when it downloads.

19
00:01:01,830 --> 00:01:04,680
It's working together and.

20
00:01:06,440 --> 00:01:11,690
It's done so on a market fires south up on a windows, you might have to double click on it, but find

21
00:01:11,690 --> 00:01:12,590
it and install it.

22
00:01:12,590 --> 00:01:16,310
If you already had go installed, you might see previous installation detected.

23
00:01:16,610 --> 00:01:17,510
If you don't, you won't.

24
00:01:17,540 --> 00:01:20,210
So just click through and accept the defaults.

25
00:01:20,630 --> 00:01:27,560
So I'm going to install it and it's trying to install it and I will allow it to do so.

26
00:01:27,560 --> 00:01:28,490
And off it goes.

27
00:01:28,490 --> 00:01:29,990
And it doesn't take long to install.

28
00:01:33,980 --> 00:01:41,210
So there it's all installed and I can verify it's installed by firing up a terminal, which I will do,

29
00:01:41,390 --> 00:01:47,210
I happen to use one called I term, but if you're on Windows, fire up a command prompt and just type

30
00:01:47,210 --> 00:01:49,340
go version.

31
00:01:49,340 --> 00:01:50,000
I think it is.

32
00:01:51,340 --> 00:01:52,930
No, Ashvin.

33
00:01:57,490 --> 00:01:58,180
Go version.

34
00:01:58,660 --> 00:02:01,930
There it is, go version one point fifteen point three.

35
00:02:01,990 --> 00:02:04,430
Now, when you're taking this course, you might be in a later version.

36
00:02:04,570 --> 00:02:07,440
Don't worry, always install the latest version.

37
00:02:08,500 --> 00:02:09,810
So that's simple enough.

38
00:02:09,820 --> 00:02:10,180
Good.

39
00:02:10,750 --> 00:02:18,070
Now let's go and find an integrated development environment and ID and I'm going to show you one that

40
00:02:18,070 --> 00:02:20,310
is free and relatively easy to use.

41
00:02:20,710 --> 00:02:24,490
It's probably not the one I'm going to use in this course, but I'll show you the one I'm using in a

42
00:02:24,490 --> 00:02:24,830
moment.

43
00:02:25,210 --> 00:02:28,500
This one is free, which is why I'm showing you how to install it.

44
00:02:28,510 --> 00:02:36,160
So let's go to Google or your favorite search engine and type in visual studio code.

45
00:02:37,810 --> 00:02:39,070
And it's the first one.

46
00:02:39,070 --> 00:02:40,210
I want to download it.

47
00:02:40,300 --> 00:02:44,790
So let's click on the download link and again, download it for your operating system.

48
00:02:44,800 --> 00:02:46,540
I'm on a Mac, so I'm choosing Mac.

49
00:02:46,540 --> 00:02:48,190
If you're on Linux, you can use this one.

50
00:02:48,190 --> 00:02:49,690
If you're on Windows, you can use this one.

51
00:02:49,690 --> 00:02:58,150
But I'm on a Mac so often comes and I'm going to save the file and I will watch the download.

52
00:02:59,450 --> 00:03:04,880
I sometimes wish I could reclaim the time I spend waiting for computers, I'd have a lot of free time

53
00:03:04,880 --> 00:03:05,630
if I could do that.

54
00:03:11,230 --> 00:03:12,910
And there it is, all downloaded.

55
00:03:12,940 --> 00:03:13,900
Now, we're not finished yet.

56
00:03:13,930 --> 00:03:14,800
We have to set it up.

57
00:03:15,820 --> 00:03:18,340
So I'm going to take the zip file on windows.

58
00:03:18,340 --> 00:03:19,150
You just unzip it.

59
00:03:19,150 --> 00:03:21,540
However, you normally unzip files on a Mac.

60
00:03:21,550 --> 00:03:23,410
I happened to use this one.

61
00:03:24,380 --> 00:03:27,610
The our but again, you can just double click on it and it will extract it.

62
00:03:28,240 --> 00:03:29,330
So it's extracted.

63
00:03:29,470 --> 00:03:32,230
Now I'm going to put that in my applications folder.

64
00:03:32,230 --> 00:03:37,470
So let's find here and find my home.

65
00:03:37,480 --> 00:03:42,370
I guess I want to go to the top level and find applications and I will drag it into my applications

66
00:03:42,370 --> 00:03:42,780
folder.

67
00:03:44,530 --> 00:03:48,730
You can put it wherever you want and start it up.

68
00:03:49,060 --> 00:03:49,960
Let's open it.

69
00:03:51,610 --> 00:03:52,780
Visual studio code.

70
00:03:54,690 --> 00:04:01,320
Yes, I do want you to open this up it comes and we're not quite done, we need to tell it about go.

71
00:04:01,320 --> 00:04:02,420
So I'm going to make this bigger.

72
00:04:03,120 --> 00:04:09,120
I'm going to go to code and preferences and find Extension's.

73
00:04:09,120 --> 00:04:11,460
So find your settings in your extension's.

74
00:04:11,860 --> 00:04:15,030
Open that up and we're going to look for gold.

75
00:04:18,180 --> 00:04:21,120
There it is right there, so let's install this.

76
00:04:23,850 --> 00:04:25,200
And it should be installed.

77
00:04:26,050 --> 00:04:26,610
OK.

78
00:04:28,350 --> 00:04:37,590
And I have to restart, so I'll quit and restart and it becomes SMIC shirts, installed preferences,

79
00:04:37,590 --> 00:04:38,580
extensions.

80
00:04:40,390 --> 00:04:40,990
Go.

81
00:04:42,840 --> 00:04:44,020
There we are, it's installed.

82
00:04:44,040 --> 00:04:46,570
OK, don't go, let's go nightly, go with the go one.

83
00:04:47,040 --> 00:04:51,570
Now, the first time you install this and I had it installed before, so I'm not seeing it, you're

84
00:04:51,570 --> 00:04:55,890
going to see a bunch of alerts show up here in the lower right hand corner asking you to install things,

85
00:04:56,250 --> 00:04:57,390
install those.

86
00:04:57,540 --> 00:05:01,350
OK, so how did this bring this up?

87
00:05:01,800 --> 00:05:03,330
Close that welcome screen.

88
00:05:03,660 --> 00:05:04,620
Now, let's open this up.

89
00:05:04,630 --> 00:05:07,920
I have no open folders, so I'm going to open a folder.

90
00:05:08,910 --> 00:05:11,760
So I'm going to open a folder and I can put this anywhere.

91
00:05:11,760 --> 00:05:20,670
I'll come in here and create a new folder called Visual Studio Projects Create.

92
00:05:21,690 --> 00:05:26,250
Inside of that, I'll create a new folder called Hello World.

93
00:05:26,460 --> 00:05:29,580
You probably saw this company coming up.

94
00:05:29,910 --> 00:05:37,350
The conventional and traditional way of of learning a new language is to create a very simple Hello

95
00:05:37,350 --> 00:05:38,310
World project.

96
00:05:38,310 --> 00:05:39,990
So let's create a new file.

97
00:05:39,990 --> 00:05:41,220
I roll over my folder.

98
00:05:41,220 --> 00:05:45,110
I've just opened in, say, new file, and I'm going to create a file called Main Dot.

99
00:05:45,120 --> 00:05:49,470
Go and Dot Go is the extension you have to give go file.

100
00:05:49,480 --> 00:05:56,220
So I'm creating a new empty file called Mango and I'm going to create a simple program that does nothing

101
00:05:56,220 --> 00:06:00,990
more than write Hello World to the screen and I'll write it to the terminal window.

102
00:06:01,560 --> 00:06:04,440
So let's start with really simple things.

103
00:06:04,440 --> 00:06:07,980
Every file in goal has to have a package.

104
00:06:07,980 --> 00:06:11,370
The first line in your file is going to be a package declaration.

105
00:06:11,370 --> 00:06:15,870
And I'm going to call this main I can call it whatever I wanted, but because this is the main part

106
00:06:15,870 --> 00:06:20,970
of my program and this is a simple program that's going to have one file, I want to give it the name

107
00:06:20,970 --> 00:06:21,330
main.

108
00:06:22,710 --> 00:06:24,870
Underneath that, I'm going to have a function.

109
00:06:24,870 --> 00:06:27,330
And that function is also called main.

110
00:06:27,330 --> 00:06:31,110
And there can only be one main function in an application.

111
00:06:31,560 --> 00:06:35,520
And the way you write functions and go and you're going to get very, very used to this as time goes

112
00:06:35,520 --> 00:06:39,000
on, is with this keyword func that says I'm a funk.

113
00:06:39,000 --> 00:06:44,550
Oh, look, there's the install things, so I'm going to install the first one is go code command is

114
00:06:44,550 --> 00:06:48,840
not available, so let's install and the second one is go packages.

115
00:06:48,840 --> 00:06:51,900
Let's install that and off it goes is installing them.

116
00:06:54,600 --> 00:06:57,450
I'll wait for that to finish all tools successfully installed.

117
00:06:57,450 --> 00:06:58,100
Perfect.

118
00:06:58,590 --> 00:06:59,190
All right.

119
00:06:59,190 --> 00:07:00,150
What's my problem.

120
00:07:00,150 --> 00:07:02,070
Expected package found EAFE.

121
00:07:02,070 --> 00:07:02,430
I know.

122
00:07:03,480 --> 00:07:04,560
So I've got that done.

123
00:07:04,980 --> 00:07:08,040
Let's call this funk main and I'll just get rid of this error message.

124
00:07:08,190 --> 00:07:15,270
It's only there because I wasn't finished typing my function func main and then I have curly brackets

125
00:07:15,270 --> 00:07:16,230
inside of that.

126
00:07:16,530 --> 00:07:20,040
I'm going to do a simple write to the screen and use that.

127
00:07:20,190 --> 00:07:24,420
You do that and go using a package called FMT or format is what I call it.

128
00:07:24,420 --> 00:07:28,380
Some people call it font, but I can't bring myself to say that regularly.

129
00:07:28,380 --> 00:07:32,790
So I call it format FMT Dot.

130
00:07:33,150 --> 00:07:37,230
And this is the nice thing about the ID is it gives me all of the auto completions.

131
00:07:37,450 --> 00:07:40,640
I'm looking for print line Primanti L.N..

132
00:07:40,680 --> 00:07:43,800
There it is, function of format, print line.

133
00:07:43,800 --> 00:07:47,080
And then inside of that I'll write Hello World.

134
00:07:48,000 --> 00:07:50,580
Now you'll notice that I have an error here.

135
00:07:50,580 --> 00:07:55,890
Still, I'm using this format function but it I need an import statement now.

136
00:07:55,890 --> 00:08:01,590
I could come up here and type in import format, but I really want this to happen automatically.

137
00:08:01,590 --> 00:08:03,300
So I'm going to go to preferences here.

138
00:08:03,300 --> 00:08:10,590
I need to find somewhere and preferences under settings I have go so I type and go.

139
00:08:10,590 --> 00:08:11,220
There it is.

140
00:08:11,820 --> 00:08:15,600
And do I have any code completion stuff.

141
00:08:18,850 --> 00:08:21,520
Um, there's go again, I guess I get out of there.

142
00:08:23,290 --> 00:08:27,220
Build flags, flags to go build no, no.

143
00:08:33,520 --> 00:08:35,980
I'm looking for the.

144
00:08:39,240 --> 00:08:40,410
The auto import.

145
00:08:41,320 --> 00:08:43,390
Where is that footpath?

146
00:08:44,200 --> 00:08:45,430
Watlington PSUV.

147
00:08:50,900 --> 00:08:52,890
Use the language server, that's what I want.

148
00:08:52,940 --> 00:08:54,320
So let's do that.

149
00:08:56,230 --> 00:09:01,060
I don't know, I need to install the go please tools, which is what I want, it installs it.

150
00:09:03,010 --> 00:09:07,450
This is an important step that will save you a lot of time, and I always have to look for it every

151
00:09:07,450 --> 00:09:09,780
time I use this because I don't regularly use this package.

152
00:09:10,660 --> 00:09:12,640
This is OK, I've got it done.

153
00:09:12,820 --> 00:09:15,640
Let's quit out of it just to make sure it's working properly.

154
00:09:15,940 --> 00:09:16,900
Started back up.

155
00:09:19,520 --> 00:09:27,920
And good, let's close the settings, go back to Main, I'm going to delete this line and I'm a FMT

156
00:09:29,150 --> 00:09:34,220
return print line and hopefully it will automatically do the part for me.

157
00:09:34,220 --> 00:09:34,850
And it did.

158
00:09:34,850 --> 00:09:40,200
It put import format in one format, print line and now hello, world.

159
00:09:41,120 --> 00:09:41,720
All right.

160
00:09:42,800 --> 00:09:43,950
So let's save this.

161
00:09:45,140 --> 00:09:45,770
There it is.

162
00:09:46,040 --> 00:09:47,600
My program is now done.

163
00:09:47,870 --> 00:09:49,480
Now I want to run this program.

164
00:09:49,580 --> 00:09:51,200
So I've written a very simple program.

165
00:09:51,200 --> 00:09:52,400
Let's just go through the things.

166
00:09:52,700 --> 00:09:56,930
First of all, every go file has to have a package declaration.

167
00:09:57,290 --> 00:10:01,310
And since we only have one file and it's the main file, the package is main.

168
00:10:01,970 --> 00:10:08,030
The import section tells the code, I am using certain packages and these could be packages in the standard

169
00:10:08,030 --> 00:10:11,090
library, which is all we're going to be using for the next little while.

170
00:10:11,090 --> 00:10:15,890
But eventually we'll go to external packages and then we have at least one function.

171
00:10:15,890 --> 00:10:18,500
And that function, if there's only one, has to be called main.

172
00:10:18,500 --> 00:10:21,020
I can have other functions and we'll do some of those in a little while.

173
00:10:21,020 --> 00:10:22,830
But right now we're just doing a very simple thing.

174
00:10:23,540 --> 00:10:29,810
So how do I run this program, this package main, which uses Fanti format from the standard library

175
00:10:29,960 --> 00:10:33,940
and all it does in the main function is write Hello World to the terminal.

176
00:10:33,980 --> 00:10:38,440
Well, I open a terminal window and in visual studio code you have a built in terminal.

177
00:10:39,050 --> 00:10:39,890
So there it is.

178
00:10:40,460 --> 00:10:43,550
And I'm going to run this now by default.

179
00:10:43,550 --> 00:10:45,860
When I open up the terminal, you can see where I am.

180
00:10:46,010 --> 00:10:52,580
I'm in my users, my name, the visual studio projects folder that I created, and then the Hello world

181
00:10:52,580 --> 00:10:57,710
folder that I created to hold this one file to run this I type.

182
00:10:57,710 --> 00:11:00,110
Go, run, maeng, go.

183
00:11:00,470 --> 00:11:07,600
And when I do that, what should happen is it should print Hello world to the screen and it does.

184
00:11:07,610 --> 00:11:08,360
Hello world.

185
00:11:08,390 --> 00:11:09,090
That's great.

186
00:11:09,140 --> 00:11:12,680
OK, now if I do, unless you see there's only one file in there.

187
00:11:12,710 --> 00:11:15,440
What if I wanted to build an executable.

188
00:11:16,020 --> 00:11:16,910
That's pretty simple.

189
00:11:16,910 --> 00:11:19,730
Go build D'Ascenzo for out.

190
00:11:19,730 --> 00:11:25,020
I want to call it HSW for Low World and what I want to compile is mango.

191
00:11:25,460 --> 00:11:27,350
So go is the command.

192
00:11:27,380 --> 00:11:29,410
You're going to get very used to using the go command.

193
00:11:29,690 --> 00:11:32,540
I want it to build and I want it to output.

194
00:11:32,570 --> 00:11:38,450
That's what the dashboard means to a file called H.W. and I want to compile mango.

195
00:11:38,450 --> 00:11:40,880
And when I do that it looks like nothing happened.

196
00:11:41,060 --> 00:11:47,630
And yet you notice up here I have a new a new file called H.W. And if I do an LS here, I have an H

197
00:11:47,630 --> 00:11:54,680
w and I can run that by doing dot slash, which says run in the current directory H.W. And all that

198
00:11:54,680 --> 00:11:56,330
does is print Hello World.

199
00:11:56,690 --> 00:12:01,250
So that is our basic setup and this is everything you need to use.

200
00:12:01,250 --> 00:12:03,170
This course you may want to install get.

201
00:12:03,170 --> 00:12:04,940
When I get to that I'll talk about that.

202
00:12:05,540 --> 00:12:12,050
But all you need to write go programs is something to create text files.

203
00:12:12,200 --> 00:12:16,910
I like an idea like Visual Studio Code and I'm going to show you the one I'm going to use momentarily.

204
00:12:16,910 --> 00:12:19,640
But Visual Studio Code is free and will do everything you want.

205
00:12:19,880 --> 00:12:27,050
You have to install the go package for Visual Studio Code and you need the go the go programming language.

206
00:12:27,050 --> 00:12:31,350
So once you install go at an idea and the necessary plug ins, you're all set.

207
00:12:32,150 --> 00:12:37,850
Now compare this to something like P, where you have to install a runtime, you have to install all

208
00:12:37,850 --> 00:12:42,950
the packages, you have to have composer, you have to have all kinds of things and keep them up to

209
00:12:42,950 --> 00:12:43,340
date.

210
00:12:43,940 --> 00:12:46,700
All you really need to write go programs is this.

211
00:12:46,820 --> 00:12:50,510
Now, there are other things we're going to use like a database later on and we'll install that.

212
00:12:50,510 --> 00:12:55,100
And it's a very simple process to do it, but it's very, very straightforward and very, very clean

213
00:12:55,100 --> 00:12:55,950
to run go code.

214
00:12:56,180 --> 00:13:01,850
Now, as I said, I don't use visual studio code and if I use it in this course, I'm going to look

215
00:13:01,850 --> 00:13:04,610
like I don't know what I'm doing because I'm just not familiar with it.

216
00:13:04,610 --> 00:13:06,140
ID nor do I want to be.

217
00:13:06,290 --> 00:13:10,460
The one I actually use is by a company called Jet Brains.

218
00:13:11,240 --> 00:13:12,350
But it's commercial software.

219
00:13:12,350 --> 00:13:13,060
You have to buy it.

220
00:13:13,640 --> 00:13:15,710
So I've got a jet Breen's dotcom.

221
00:13:18,540 --> 00:13:23,650
Up it comes, and I want to use go, I want to write, I want to write things in goes.

222
00:13:23,660 --> 00:13:26,920
I'm going to scroll down to find gold and click on that.

223
00:13:27,370 --> 00:13:29,230
And it becomes it says Goaland.

224
00:13:29,230 --> 00:13:31,060
This is exactly the one that I use.

225
00:13:31,060 --> 00:13:33,660
And it's it's just another idy.

226
00:13:33,670 --> 00:13:36,310
The only reason I use it is because I'm familiar with it.

227
00:13:36,550 --> 00:13:41,410
You can get it free if you happen to be a student in an educational institution, you can get it free

228
00:13:41,410 --> 00:13:44,740
if you're using it for an open source project.

229
00:13:44,740 --> 00:13:49,210
But of course you actually have to have a project that is open source that they can look at, or you

230
00:13:49,210 --> 00:13:52,810
can download the three day trial and try it out if you like it by it.

231
00:13:52,810 --> 00:13:56,070
If you don't like it, go back and learn and use visual studio code.

232
00:13:56,080 --> 00:13:57,270
It's entirely up to you.

233
00:13:57,610 --> 00:14:02,920
This is what I'm probably going to use as we go through this course just because I'm so much more familiar

234
00:14:02,920 --> 00:14:03,220
with it.

235
00:14:03,490 --> 00:14:06,340
But the differences really are pretty straightforward.

236
00:14:06,340 --> 00:14:07,930
You're still going to have go files.

237
00:14:07,930 --> 00:14:09,280
You're still going to have a terminal.

238
00:14:09,580 --> 00:14:11,170
Everything will be almost the same.

239
00:14:11,170 --> 00:14:13,570
I'm just going to have a slightly different interface than you are.

240
00:14:13,720 --> 00:14:17,140
But anyway, we've now got a one functional go program.

241
00:14:17,800 --> 00:14:21,220
Let's get started and do something that's actually useful.
