1 00:00:13,880 --> 00:00:17,750 Hello and welcome to the goal and programming language course. 2 00:00:19,070 --> 00:00:26,030 In this session, we want to talk about create an example for lead and ride the fine and go language. 3 00:00:27,420 --> 00:00:34,350 In this sample, the user is supposed to receive information from the council and save the received 4 00:00:34,350 --> 00:00:41,190 information inside the file and then read the information is stored inside the file and display it. 5 00:00:41,790 --> 00:00:46,410 Now let's go to this school for a year to read and write the fine. 6 00:00:48,700 --> 00:00:55,510 First, create a function named create fine for creative fine and write data inside it. 7 00:00:56,290 --> 00:01:01,300 In this function, we defined two parameters pass file name and find content. 8 00:01:03,070 --> 00:01:04,180 So define 9 00:01:06,730 --> 00:01:07,270 foreign. 10 00:01:09,280 --> 00:01:15,430 Create five set two parameters first, find the. 11 00:01:17,350 --> 00:01:20,830 And second, text and type of there is a strike. 12 00:01:24,570 --> 00:01:32,320 Creating the file using create function, which user interrupted fine name and or variable so defined 13 00:01:32,330 --> 00:01:43,200 by comma here equals in create fun from Westpac case or start, create fine and set file name. 14 00:01:46,820 --> 00:01:55,010 Now we check to print a message for us if the error is not empty, so right, if error not equals to 15 00:01:55,010 --> 00:01:55,520 mean. 16 00:01:58,590 --> 00:02:13,440 Colin Fatalis from launch function last Saturday, left and right, a message failed to create five 17 00:02:14,100 --> 00:02:18,810 column percentages and set a rule value about. 18 00:02:23,000 --> 00:02:29,360 Now, closing the running fine after the main method has completed the execution and the writing to 19 00:02:29,360 --> 00:02:30,650 the file is complete. 20 00:02:30,980 --> 00:02:38,000 So views from different keyboard differ and close the font file close. 21 00:02:39,680 --> 00:02:45,230 Now writing data to the using write history, so first define tool variable. 22 00:02:45,230 --> 00:02:51,050 First, Len and Edward Cullen equals fine dot. 23 00:02:51,500 --> 00:02:52,640 Write a string. 24 00:02:55,110 --> 00:02:56,310 And it takes. 25 00:02:57,450 --> 00:03:07,290 As our humans now we take to create a message for us, if the error is not empty, if a row not equals 26 00:03:07,290 --> 00:03:16,680 to mean so fat on Earth, from large package life to fatal Earth and Saturn message hail 27 00:03:19,620 --> 00:03:20,580 writing 28 00:03:22,890 --> 00:03:30,090 to fire color, cursing Earth and such error message. 29 00:03:31,650 --> 00:03:36,100 Now print name and lengths of function by following code. 30 00:03:36,650 --> 00:03:49,130 If bank is less than five, nine per cent is set by that name. 31 00:03:50,250 --> 00:03:50,850 If if. 32 00:03:51,860 --> 00:03:54,800 I guess less and less. 33 00:03:56,200 --> 00:04:03,800 Colin, persons since the Whites said, Len, very. 34 00:04:05,590 --> 00:04:11,980 Reformat the code, then save the project, we were able to create a function that receives two parameters 35 00:04:11,980 --> 00:04:18,670 can't find a name and file content as takes from the outside, then creates the desired file and is 36 00:04:18,670 --> 00:04:21,490 supposed to receive information inside the phone. 37 00:04:22,300 --> 00:04:27,850 Now we want to create the function to read and display the information is stored and defined. 38 00:04:29,510 --> 00:04:35,540 First, create a function name, Redefine and set the parameters fine name, phone. 39 00:04:37,010 --> 00:04:45,380 Read fine and set a parameter name by name as a stream. 40 00:04:49,800 --> 00:04:53,310 Display a message based on reading fine information. 41 00:04:53,370 --> 00:05:00,060 The fear that is less and reading the. 42 00:05:06,070 --> 00:05:13,510 To read data from DeFi, the use redefine function of AI or UTIL package redefine function reads the 43 00:05:13,510 --> 00:05:17,350 fine named by file name and returns the contents. 44 00:05:17,860 --> 00:05:25,480 This function returns to variables as bias area, and they're also first defined to variable like data 45 00:05:25,480 --> 00:05:27,580 and URL column equals. 46 00:05:28,240 --> 00:05:36,910 Invoke redefined function from AI to take each dot read fine. 47 00:05:37,900 --> 00:05:46,150 And sit fine, Amos arguements fine name in case of an error, the erroneous statement is printed and 48 00:05:46,150 --> 00:05:53,980 program is a start, so we'll be right if are not equal to mean. 49 00:05:56,700 --> 00:06:06,810 We use from panic, a function from like package locked door punch if and set a message, fail. 50 00:06:07,990 --> 00:06:16,270 Reading data from five columns per cent is an said error of value that. 51 00:06:18,240 --> 00:06:25,080 In this case, we display fine line lengths of fine and fine contents by the following code. 52 00:06:25,320 --> 00:06:32,010 Defensive back slash and fine name calling. 53 00:06:32,870 --> 00:06:36,350 Yes, and set fire and then variable. 54 00:06:38,220 --> 00:06:54,540 If Earth patches list and size per cent the ice and set then of data. 55 00:06:55,850 --> 00:07:02,490 Variable and back, yes, list and data. 56 00:07:03,070 --> 00:07:06,760 Colin Person is said data, right? 57 00:07:09,580 --> 00:07:11,800 Reformat the code and save the project. 58 00:07:11,950 --> 00:07:19,660 Now we were able to create the function that receives defined name as an input parameter and then reads 59 00:07:19,660 --> 00:07:23,410 the information inside the received file and display it. 60 00:07:23,620 --> 00:07:31,630 Now we can create two functions one function to create the fine and save the information inside it and 61 00:07:31,630 --> 00:07:35,590 the other function to read the existing information from the fire. 62 00:07:35,800 --> 00:07:43,690 It's time for the user to receive information from the council inside the main function and to write 63 00:07:43,690 --> 00:07:48,730 and read the information by calling the functions created in the main method. 64 00:07:49,330 --> 00:07:51,460 So go to main function. 65 00:07:58,520 --> 00:08:06,170 User input for finding the first display, a message to let the user know that they need to enter information 66 00:08:06,170 --> 00:08:12,050 FP into by name 67 00:08:15,440 --> 00:08:20,990 and define a variable for assigned file name to it by using its own function. 68 00:08:21,260 --> 00:08:36,020 First, define the variable like that file name type is a string and define 2.0 scanlon and set and 69 00:08:36,020 --> 00:08:38,410 person file name. 70 00:08:39,500 --> 00:08:43,430 Now, using input for five content, we do this again. 71 00:08:43,430 --> 00:08:53,340 First display a message to let the user know that they need to enter information, so write F.P. into 72 00:08:53,990 --> 00:08:54,740 text 73 00:08:57,920 --> 00:09:00,200 to read information from the council. 74 00:09:00,200 --> 00:09:08,120 We use for a new reader function that returns in new reader, whose buffer has the default size and 75 00:09:08,120 --> 00:09:15,290 assign it to a variable like input reader input reader. 76 00:09:16,070 --> 00:09:29,420 Column equals invokes new reader function from both I or package, while I o but new reader and sit 77 00:09:29,420 --> 00:09:37,130 a standard input as argued or stored listed in now. 78 00:09:37,140 --> 00:09:44,960 Views from reader soon function for reading the text reader string function reads until the first occurrence 79 00:09:44,960 --> 00:09:51,800 of delimiter in the input returning Estyn containing date data up to and including the delimiter. 80 00:09:52,130 --> 00:09:58,610 If we string encounters an error before finding a delimiter, it retains the date on read before the 81 00:09:58,610 --> 00:10:00,200 error and error itself. 82 00:10:00,920 --> 00:10:06,140 So first, define the variable like improved chrome on a school call. 83 00:10:06,140 --> 00:10:08,960 It equals input reader 84 00:10:12,620 --> 00:10:14,260 dot reader string. 85 00:10:16,040 --> 00:10:24,920 We set a delimiter for the example backslash and either able to receive the information from the outside 86 00:10:24,920 --> 00:10:25,700 environment. 87 00:10:26,030 --> 00:10:34,910 Now we have to write and read and display it again to their to existing functions inside, define first 88 00:10:34,910 --> 00:10:42,630 involved, create file function and post two variables file name as foreign name and input as file content 89 00:10:42,630 --> 00:10:51,080 to either create fine first, finally and second input. 90 00:10:53,590 --> 00:11:00,940 Then invoke redefine function and pacifying them as argument to fetch data from five fold, we write, 91 00:11:00,940 --> 00:11:10,600 read fine and certified nay, reformat the code, save the project and execute the program. 92 00:11:15,480 --> 00:11:20,510 Inter Define, named for the example, test the RTX three. 93 00:11:21,680 --> 00:11:22,550 Initiatives. 94 00:11:23,270 --> 00:11:30,140 Hello and welcome to go programming. 95 00:11:31,200 --> 00:11:32,100 Language 96 00:11:35,670 --> 00:11:44,820 now we can see the output file name is pierced, the text length is 46 bytes reading a fine and then 97 00:11:44,820 --> 00:11:46,380 again fine, then test. 98 00:11:46,380 --> 00:11:50,340 The text size is for six bytes and data. 99 00:11:50,340 --> 00:11:50,580 Please. 100 00:11:50,600 --> 00:11:53,440 Hello and welcome to go programming language. 101 00:11:54,060 --> 00:12:00,720 We were able to get the information from the console right, eat in the phone and then read the information 102 00:12:00,720 --> 00:12:07,410 from the file and display it in order not to prolong the time of decision to will finish it, and we 103 00:12:07,410 --> 00:12:09,910 will continue the content in the next session. 104 00:12:09,930 --> 00:12:10,490 Goodbye.