WEBVTT 00:01.660 --> 00:05.320 Welcome back in this section, you're going to learn about trucks. 00:05.680 --> 00:06.480 Let's get started. 00:08.310 --> 00:15.170 Strikes allow us to represent concepts by declaring a blueprint for a set of related types in a single 00:15.170 --> 00:15.420 time. 00:15.800 --> 00:22.490 For example, you can create a person's truck to represent the person, or you can create a movie struck 00:22.490 --> 00:29.120 for a movie recommendation engine, or you can create a rental truck to create a rental listing program 00:29.120 --> 00:29.790 and so on. 00:30.410 --> 00:32.720 These are called the strike fields. 00:32.990 --> 00:38.450 For example, in the rental truck address room's size and price. 00:38.460 --> 00:41.180 All are the fields of the rental truck. 00:41.480 --> 00:44.810 Of course, you can give anything that you want to a field. 00:45.050 --> 00:48.950 As you can see, different trucks can have a different set of fields. 00:49.220 --> 00:51.650 That is the main idea behind this truck. 00:52.160 --> 00:55.730 It is to shape your own types using other types. 00:56.390 --> 00:59.270 Let's take a look at the first truck type as an example. 00:59.860 --> 01:01.970 A type is a blueprint. 01:02.330 --> 01:05.800 So there is a difference between a strike type and a strike value. 01:06.020 --> 01:07.700 You'll see what I mean in a minute. 01:08.450 --> 01:12.890 If you are familiar with or pee, you can think of a strike as a class. 01:13.280 --> 01:19.580 They are similar to classes in Java, C, sharp Python and JavaScript or strikes in C language. 01:20.180 --> 01:27.050 By using strikes, you can group related data about a single concept together in a single strike type. 01:27.710 --> 01:34.670 A struct type is fixed at compile time, so you cannot change the field names and types in runtime. 01:34.940 --> 01:40.070 This also means that you cannot add new fields to a structure in runtime. 01:40.370 --> 01:45.980 For example, name, last name and age are the fields of the person strike type. 01:45.980 --> 01:48.120 So they are fixed at compile time. 01:48.230 --> 01:52.180 It's because you can create a struct type only at compile time. 01:52.610 --> 01:56.090 However, you can use the person struct type as a blueprint. 01:56.360 --> 02:01.820 Through that you can create as many person values as you want in runtime like so. 02:02.630 --> 02:07.850 As you can see here, I create different person values using the same person type. 02:10.010 --> 02:15.450 Like everything in go, you need to declare each track field with a specific type. 02:15.710 --> 02:22.040 For example, you can declare the first two fields as string fields like so, and you can declare the 02:22.400 --> 02:24.290 field as an event like so. 02:24.680 --> 02:30.680 As you know, you can only store the same type of elements in an array or map. 02:30.890 --> 02:37.370 However, which tracks you can also store different types of data in the same single type. 02:37.940 --> 02:44.210 This part belongs to compile time, so you need to declare the field names and their types at compile 02:44.210 --> 02:48.830 time so they are fixed at compile time and you cannot change them in runtime. 02:50.150 --> 02:55.670 However, the field values belong to runtime, so you can change them in runtime. 02:56.180 --> 03:03.200 Let's take a look at the differences between slices, maps, anthrax slices and maps can only store 03:03.200 --> 03:04.890 the same type of values. 03:04.910 --> 03:11.840 However, strikes can store different types of values because they may have different types of fields. 03:12.710 --> 03:15.500 Slices and maps can grow in runtime. 03:15.740 --> 03:20.420 As you know, you can add new elements to them or you can remove the existing elements. 03:20.900 --> 03:26.500 However, Scruggs fields are fixed at compile time so they cannot grow in runtime. 03:26.660 --> 03:29.950 You cannot add new fields to a structure in runtime. 03:30.170 --> 03:31.400 Neither you can remove them. 03:31.880 --> 03:35.680 Now let's take a look at how you can declare a truck using a truck. 03:35.690 --> 03:40.830 Literally destruct type represents a video game, as you learned. 03:41.060 --> 03:44.300 These are the fields names and these are the field types. 03:44.960 --> 03:50.900 You can name a field however you want, and as you can see, each one of them can have a different type. 03:51.140 --> 03:52.100 There is one rule. 03:52.100 --> 03:54.590 The field names should be unique. 03:55.310 --> 03:59.120 Let's create a strike value using the video game here. 03:59.120 --> 04:00.770 I put it in Peckman variable. 04:01.070 --> 04:03.040 As you can see, this is a composite literal. 04:03.260 --> 04:05.090 You know the syntax very well. 04:05.090 --> 04:07.230 So the struct literal is no different. 04:07.850 --> 04:09.110 These are the field names. 04:10.390 --> 04:16.720 And these are the field values, for example, the title is a Stringfield, so you cannot store and 04:16.720 --> 04:18.060 numeric value in it. 04:18.160 --> 04:24.220 You can only store a street value or the published field is a ball field, so you cannot store a string 04:24.220 --> 04:24.840 value in it. 04:25.120 --> 04:28.190 You can only store a bool value and so on. 04:28.600 --> 04:29.080 All right. 04:29.350 --> 04:31.100 That's enough theory for now. 04:31.630 --> 04:33.040 See you in the next lecture by.