Transcript from the "Go Basics Overview" Lesson
[00:00:34] And typically, we ship bytecode. So we deploy bytecode, and that's, for example, Java or C#. So we compile. We don't deploy .java files, we deploy .class files typically grouped in a container. And then we have compiled languages that are actually creating directly machine codes. So a code that executes directly in one CPU within the context of one operating system.
[00:01:34] That is what we will do here today, okay? But we are there, so we don't compare go with Python in terms of the nature of the language. We compare that more with C, okay? So fundamentals of the Go syntax. Basic rules, we use .go files. We saw that in action.
[00:01:59] We use code blocks, curly braces. So we don't care as in Python about spaces or tabs that we have. We don't care about indentation, it's just about curly braces. We don't have a styling freedom, and you didn't see that yet, but you will in 15 minutes. We do have semi-colons to separate sentences, but it's optional.
[00:02:24] And the best practice is not to use them unless, for some reason, we are defining two sentences in the same line, okay? So if you have two prints in the same line, well, you must separate those print calls with a semi-colon, but we are not going to see semi-colons a lot, yeah.
>> Does that mean it reads new line as a delimiter?
>> Yeah, so a new line is a delimiter, but it's not always true because, let me show you something, and that's a spoiler. I can do this. And you can see it's giving me an error, okay, say, let me open from here.
[00:03:09] What's going on here? What is that? Have a lot of errors. That's first one to go, this one. A string literal not terminated, but I can make it work pretty easily, and also, I can print more stuff and go to a new line. And on some situations, well, we didn't create variables yet, so I don't wanna show you that.
[00:04:30] But it's for some special cases. We are not going to use them. If you are used to that, yeah, you need to train your brain, okay? Use the machine learning capability that you have in your brain to train it to not use semicolons. Okay, so we already said that it's optional.
[00:05:13] So every variable will have a type and we can't change that type dynamically. We will see later how we can do some dynamic things because sometimes we have some use cases. But first, let's start, this is a strongly typed language. And it's not an object-oriented language. We don't create classes.
[00:05:37] We don't create objects. So no classes, also we don't have exceptions. Try-catch, no, they don't exist here. We don't have something known as an exception. We do have a way to throw a fatal error. We will see how to do that. And also we have a design pattern to work with errors, and we will see how that works as well.
[00:06:05] But that's not what you know as exceptions. We don't have try-catch. It's going to be something different. Again, if you're asking, why, why? Remember there are three goals, that's why. Adding that will probably, in this case, affect execution performance. So we have typically one file acting as the entry point.
[00:06:30] That's the one that we need so far. It has a main function. Then we're going to start adding more stuff, for example, what's a package? A package is a folder, okay? We will start working with that in a minute. Packages can have simple names such as, services, utilities, data, or URLs.
[00:06:53] So you can actually use a URL as a package name, but doesn't need to actually match a real URL. And within one Go file, so in .go file we can have variables, functions, so far we did only one function, type declarations, we haven't seen one yet, and methods declaration.
[00:07:19] We will cover all of this, okay? But we will have Go files with variable functions, type declarations, and methods declaration. There is a constant, well, that typically goes under the variables umbrella. And then we have modules. What's a module? Roughly and quickly, a quick and dirty definition, a project.
[00:07:42] So far, we have just created only one file without a module. So it wasn't actually a Go application, it was a standalone script. That is not common, okay? So typically, you don't do that. So you create a module.