1 00:00:14,000 --> 00:00:19,100 Hello and welcome to the Golang programming language course in this session. 2 00:00:19,160 --> 00:00:21,980 We want to talk about interface concept. 3 00:00:26,420 --> 00:00:27,920 In their faces and go blank. 4 00:00:30,200 --> 00:00:37,610 Go language interfaces are different from other languages in gold language, the interface is a custom 5 00:00:37,610 --> 00:00:42,830 type that is used to specify a set of one or more message signatures. 6 00:00:44,020 --> 00:00:51,880 Interface is abstract, so you are not allowed to create an instance of the interface, but you're allowed 7 00:00:51,880 --> 00:00:58,660 to create a variable of an interfaces type and display, but it can be a sign with a concrete time value 8 00:00:58,900 --> 00:01:04,270 that has the metals being their face requires or in other laws. 9 00:01:04,270 --> 00:01:08,470 Dana Face is a collection of missiles, as well as cost them time. 10 00:01:09,460 --> 00:01:16,990 How to create an interface to create an interface using either face keyboard, followed by clearly braces 11 00:01:17,170 --> 00:01:23,170 containing a list of method names along with any parameters or returned values. 12 00:01:23,380 --> 00:01:25,180 The missiles are expected to have. 13 00:01:26,310 --> 00:01:28,920 Now you can see the scene techs. 14 00:01:31,110 --> 00:01:39,210 Declare an interface, time and missiles does not have a body and in their faces act as a blueprint 15 00:01:39,210 --> 00:01:43,530 for method since they must be implemented before being used. 16 00:01:43,890 --> 00:01:48,150 Type that satisfies and interface is said to implement it. 17 00:01:52,910 --> 00:01:55,460 How to implement interfaces. 18 00:01:56,590 --> 00:02:02,950 In the gold language, it is necessary to implement all the methods, the clearing, the interface for 19 00:02:02,950 --> 00:02:10,690 implementing an interface, the gold language interfaces are implemented implicitly and it does not 20 00:02:10,690 --> 00:02:16,480 contain any specific keyboard to implement an interface just like other languages. 21 00:02:17,560 --> 00:02:22,990 Let's go to this school program to illustrate how to implement an interface. 22 00:02:25,390 --> 00:02:37,530 First, go to Explorer and create a project folder like in interfaces and create a file name Lee. 23 00:02:37,990 --> 00:02:46,200 So let's go hack each main and function function. 24 00:02:49,750 --> 00:02:57,670 First, create an interface named rectangle and has two methods for triangulate rectangle three Trinitarian 25 00:02:57,700 --> 00:02:58,210 area. 26 00:03:02,520 --> 00:03:03,180 Tie. 27 00:03:06,470 --> 00:03:07,640 Rectangular. 28 00:03:11,050 --> 00:03:11,980 Interface 29 00:03:14,410 --> 00:03:16,210 and create two methods. 30 00:03:19,930 --> 00:03:36,490 Preemie to return tide is low 64 and area uterine tide is again below sixty four, set a common for 31 00:03:36,490 --> 00:03:38,140 these NFA for export 32 00:03:42,340 --> 00:03:45,580 rectangular interface. 33 00:03:50,610 --> 00:03:57,690 In order to be able to use the methods of an interface, we need to implement them to implement the 34 00:03:57,690 --> 00:03:59,190 methods of interface. 35 00:03:59,400 --> 00:04:04,340 We need to create a struct now creating an abstract. 36 00:04:05,520 --> 00:04:06,380 Times 37 00:04:09,000 --> 00:04:09,590 change. 38 00:04:09,900 --> 00:04:12,750 Q Let's say the name for this is right. 39 00:04:13,560 --> 00:04:14,420 That's right. 40 00:04:18,450 --> 00:04:19,090 This is wrong. 41 00:04:19,110 --> 00:04:25,830 It has two fields length and type of fields to load 64. 42 00:04:26,640 --> 00:04:28,140 And the other is weeds. 43 00:04:30,300 --> 00:04:31,710 Typekit is in the game. 44 00:04:31,920 --> 00:04:33,330 Loads 64. 45 00:04:34,910 --> 00:04:37,400 Sit the comment for export, distract, 46 00:04:40,220 --> 00:04:42,510 calculate, distract. 47 00:04:46,670 --> 00:04:52,160 OK, now implementing methods of reigniting your interface via the striked receiver. 48 00:04:53,030 --> 00:05:00,380 First, implement pre-internet or farm city receiver. 49 00:05:00,600 --> 00:05:03,260 C Calculate 50 00:05:06,260 --> 00:05:07,400 free meter 51 00:05:09,950 --> 00:05:11,720 and return time flow. 52 00:05:11,750 --> 00:05:16,730 64 and dismantled reader 53 00:05:20,360 --> 00:05:27,230 C dot widths plus C dot links. 54 00:05:29,070 --> 00:05:31,680 And told her medication to 55 00:05:34,850 --> 00:05:46,350 set a common for dismantled three metre missile and second in demand early on, this would 56 00:05:49,710 --> 00:06:05,490 find three Silver Sea calculate and area that will reach inside to load 64 and set of body for this 57 00:06:05,760 --> 00:06:08,230 method later. 58 00:06:10,000 --> 00:06:19,230 See, don't this multiplication see the legs set the common for peace central 59 00:06:22,770 --> 00:06:23,430 area? 60 00:06:25,650 --> 00:06:31,560 OK, now go to main function for accessing elements of the rectangle interface. 61 00:06:33,450 --> 00:06:35,310 Go to the main function. 62 00:06:36,090 --> 00:06:43,380 First, create an interface value that from the H9, get and then initialize it by calculate struct 63 00:06:43,950 --> 00:06:48,210 that are rectangular. 64 00:06:49,630 --> 00:06:56,410 Define and variable from a rectangle in the first and in the next line, the initial lines are by the 65 00:06:56,410 --> 00:07:06,070 calculator strikes are equals, calculate for the example, 20 and 10 66 00:07:08,650 --> 00:07:14,500 now invoke rectangle interface, metals and display, then go to the next line. 67 00:07:15,040 --> 00:07:15,790 If P 68 00:07:19,810 --> 00:07:32,020 three metre or rectangle color are dots printer, go to the next line. 69 00:07:32,560 --> 00:07:48,730 If P area of rectangle column, ask dot area, reformat the code, save the project and execute the 70 00:07:48,730 --> 00:07:50,230 program first. 71 00:07:50,230 --> 00:07:59,600 Go to Project Folder, see the interface and run the project by the Kremlin to run. 72 00:08:00,640 --> 00:08:02,010 Name the group. 73 00:08:02,960 --> 00:08:06,310 Now you can see the output in this case. 74 00:08:06,310 --> 00:08:09,850 First, create an interface has two methods four. 75 00:08:09,850 --> 00:08:12,940 Calculate a rectangle, perimeter and area. 76 00:08:15,150 --> 00:08:23,310 In order for us to be able to use them, we have to implement them, so we create a strong name, calculate 77 00:08:23,490 --> 00:08:28,740 and implement two rectangle interface methods and assign them to instruct. 78 00:08:29,010 --> 00:08:33,750 Now define variable from rectangle interface and initialize. 79 00:08:33,750 --> 00:08:39,360 It will calculate the strike and coding tooling interface methods and see the result. 80 00:08:40,230 --> 00:08:48,150 Assigning an instance of calculate strike to a variable of rectangle interface, time works because 81 00:08:48,360 --> 00:08:53,430 calculator strike implements both perimeter and area method of the calculate. 82 00:08:54,120 --> 00:08:57,510 The time is not changed during this assignment. 83 00:08:57,750 --> 00:09:06,480 Instead, it is enough to check that the type assigned does implement perimeter and area method in order 84 00:09:06,480 --> 00:09:08,430 not to prolong the time of decision. 85 00:09:08,460 --> 00:09:12,480 We will finish it and we will continue the content in the next session. 86 00:09:12,750 --> 00:09:13,290 Goodbye.