Welcome back in this section, you're going to learn about trucks.
Let's get started.
Strikes allow us to represent concepts by declaring a blueprint for a set of related types in a single
time.
For example, you can create a person's truck to represent the person, or you can create a movie struck
for a movie recommendation engine, or you can create a rental truck to create a rental listing program
and so on.
These are called the strike fields.
For example, in the rental truck address room's size and price.
All are the fields of the rental truck.
Of course, you can give anything that you want to a field.
As you can see, different trucks can have a different set of fields.
That is the main idea behind this truck.
It is to shape your own types using other types.
Let's take a look at the first truck type as an example.
A type is a blueprint.
So there is a difference between a strike type and a strike value.
You'll see what I mean in a minute.
If you are familiar with or pee, you can think of a strike as a class.
They are similar to classes in Java, C, sharp Python and JavaScript or strikes in C language.
By using strikes, you can group related data about a single concept together in a single strike type.
A struct type is fixed at compile time, so you cannot change the field names and types in runtime.
This also means that you cannot add new fields to a structure in runtime.
For example, name, last name and age are the fields of the person strike type.
So they are fixed at compile time.
It's because you can create a struct type only at compile time.
However, you can use the person struct type as a blueprint.
Through that you can create as many person values as you want in runtime like so.
As you can see here, I create different person values using the same person type.
Like everything in go, you need to declare each track field with a specific type.
For example, you can declare the first two fields as string fields like so, and you can declare the
field as an event like so.
As you know, you can only store the same type of elements in an array or map.
However, which tracks you can also store different types of data in the same single type.
This part belongs to compile time, so you need to declare the field names and their types at compile
time so they are fixed at compile time and you cannot change them in runtime.
However, the field values belong to runtime, so you can change them in runtime.
Let's take a look at the differences between slices, maps, anthrax slices and maps can only store
the same type of values.
However, strikes can store different types of values because they may have different types of fields.
Slices and maps can grow in runtime.
As you know, you can add new elements to them or you can remove the existing elements.
However, Scruggs fields are fixed at compile time so they cannot grow in runtime.
You cannot add new fields to a structure in runtime.
Neither you can remove them.
Now let's take a look at how you can declare a truck using a truck.
Literally destruct type represents a video game, as you learned.
These are the fields names and these are the field types.
You can name a field however you want, and as you can see, each one of them can have a different type.
There is one rule.
The field names should be unique.
Let's create a strike value using the video game here.
I put it in Peckman variable.
As you can see, this is a composite literal.
You know the syntax very well.
So the struct literal is no different.
These are the field names.
And these are the field values, for example, the title is a Stringfield, so you cannot store and
numeric value in it.
You can only store a street value or the published field is a ball field, so you cannot store a string
value in it.
You can only store a bool value and so on.
All right.
That's enough theory for now.
See you in the next lecture by.