Golang Mock Interview for fresher Part -1 theory || #golang #codingconcepts #interview #mock ||

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
foreign [Music] with 6.7 cgpa overall and till now I have learned the go language implemented basic syntax in the go language a challenge is wise I used to participate in code shape basically do the some competitive programming kind of things so that is to increase by skills okay so uh as you said you have done the golang so how do you know about golang first uh yeah like a typical college student uh when we are in a third year or final year our goal is to create one of the website uh so I am also on the same track trying to create one website so I came to know like HTML CSS is highly uh needed in as uh creating one of the websites so I learned HTML CSS the teacher who was teaching me the HTML CSS at the end he said that only by HTML CSS I cannot create the website he gives some insight of go language from the uh there only he gives some comparison also like he give comparison with PHP and after doing analysis from my side I choose go language so that is I think third year of my college in 2018 uh so you are talking about that uh there is some Advantage between uh your back end uh languages like you have said PHP and other languages so what are the benefits of using Golan uh uh so there are two advantages two advantages not two advantages two prospective advantages I can say one is as a developer perspective another is a as a company perspective so for a company uh if I say it is something like golang is going to save the money if I have to deploy a website and that website is running uh let's say 600 requests per second and somehow I can minimize the memory uses and RAM uses uh so in that case I can save the money because Cloud basically charges based on the amount of Ram or memory we are consuming so in that case go is going to be very helpful for them because it is consuming very less memory so that is the company perspective now as a developer what I can say is like uh I have to give the reason also like why it is consuming less so I think that was the advantage point of the goal language like uh PHP if I compare PHP is not build uh when there is multiple core processors are there but uh when multiple cores came in in picture then we just keep on modifying the PHP compiler so that it can take advantage of multiple cores same goes with Java and python also so we can see that go is something which is built in the era where multiple core CPUs are already there and it is basically built to use this feature very efficiently for example I can say is like in Java it consumed close to one MB of memory just to run one thread whereas go consume 4 KB or just to run a go routine so both of them are same but you can see this size of memory so that is where go is having much of the advantage other Advantage also like it is very lightweight very close to human English and easy to learn also lightweight in the sense not very complex programming language so it a small language very easily can be learned other thing is like same with because of a small language there is disadvantage also Advantage also uh it's the it's just the way we are seeing it it is like let's say if we have lots of website running we already know there are millions of website may be running at the moment so close to 95 percent of the website is not that complex so go can efficiently achieve that or can be created create that website in go language but if you follow other languages they can also create but at that time they are not going to be as efficient so that this is also what I can say is like I have I try to give both picture of small language advantage and disadvantage okay uh so uh let's come come on today like the advantages we have already done and disadvantage you have included in your answers and so I will go with the how you create a project so we have a workspace thing like in go so how you define and how you do that thing so project wise we basically uh stick with workspace or a place where we do the coding so in go language there are two things a path variable and root variable so root variable is where our go language is installed basically where our compiler sits uh whereas the path variable is where our workspace and workspace is where we do our coding like create our projects let's say if we have to create a project for a school then we do it on the workspace and that is where our path variable also points the same location not exactly same but in the bin folder of the workspace your voice is little bit breaking up yeah CMI also fill the scene your voice also hello okay okay yeah so uh also without a goruto without a gopat we can't uh create a project is it right no is there anything else we can go for it yeah now there is things like now we have dependency management uh like go mod file basically that manage the dependencies so now that with the help of mod file we can create a project outside the workspace also okay fine so that's the answer which I want okay uh so what is packages in bowling packages what I can say is a smaller unit of a project which we divide or divide uh in order to make a better readability and sometimes we achieve security also using the packages so I can say packages is a kind of liability if it is not not a main package if it is a main package then it is a kind of executable file so let's say for example we have model and we have executable fun model can all the structure can be defined in single package and we can import that so that is a way of organizing our code so go is uh very uh the following package go is going to help us our code to organize better for the redevelty and readability purpose yeah so what is constants and variables in uh go what are we how can you distinguish between those things what is constant and variable yeah so what I can say is like when we say constant it means if a value is initialized with anything let's say if it is integer constant and if I set the value to 1. so after set to 1 now it cannot be changed it will be one always let's say if that was variable for example in that case after getting set to 1 again we can change it to 2 5 10 whatever we want so variable means whatever we are assigning can be changed whereas if constant then once assigned then never can cannot be mutated okay uh so how can we assign the variable single language so variables is like there are multiple ways of creating variables and uh there is sort hand operator also in go language so we can use keyword where and variable in name and type of the variable and then with the equal to sign we can assign okay fine uh so we have different data types in Google and uh could you describe all of them yes so I'll try to uh describe as many as possible because there are lots of data types in go language uh so basically I can classify in four of them basically integer string float and then we can say uh integer string float and then Boolean okay now these are the I think yeah go ahead yeah these are the I can say core of the data type then integer can be divided in multiple Parts based on their size like int 8 into 64 in 32 and into also uh float also same goes so now it's just the matter of size of the flag we have runes also we have bytes also in go language yep so these were I think the primitive data types there are non-preemptive data type also so basically uh this is one another classification Factor where we say primitive and then primitive Prim TV is basically which are fundamentally available whereas non-primitive are those data type which are built using these fundamental data types or I can say it is a user defined data type like a structure in a structure we can have uh many other many fields of any fundamental type of data type or any nested structure itself so that can also have non-prem tip type but the core concept is uh non-prem TV is collection of fundamental uh you can say data type yeah fine uh so yeah you heard about the slicing Woolen uh did you heard yes what is slice and uh could you differentiate between the area and the slice yes slice I can say is a linear uh structure uh which store any particular type particular type in the sense if I say area of integer then it is going to store only integers if area fishing it is going to store only uh strings and I can say it is a linear structure and it can uh what I can say is like it is collection of multiple units of that particular type the basic difference between slice and array is like when we give the length let's say if I wanted to store 10 units and I am sure that it is going to be 10 then we pick the array sometimes what happens is like we are not sure how minis are going to be there in that case we can go with the slides so if I summarize it in sort then I can say slice is of dynamic length whereas arrays of fixed length uh one example which I'd like to give is like let's say if we have security purpose where we know the password character should be of 4 digit then we go with the array because in that case if I uh use slice then fifth character can also be appended so we choose the four elements so for sure there should be four digit PIN so array is better option but when we uh choose slice so let's say if there is admission is going on and for that we uh we are taking admission forms so so any number of admission forms can be in so for that we can go with slice so I think this is real example yeah fine fine so what is interface in golang uh interface uh I can say uh it is very important ah thing in go language basically it uh it takes go language from a completely non object oriented programming language to close to object oriented programming language because it provides the feature of method overloading another thing is like we can use interface as a variable also so basically when we use interface as a variable then we are saying that we can assign it anything like integer also string also float also and it is not like once we assign integer then I cannot assign a string same if I create a variable a of type integer sorry interface then I can assign a to integer and A2 string so any you I can change the type also and another thing is like it's sometimes used for method declaration also or methods signature so basically that is uh help us in method overloading sometimes we use this use this for mocking also for our unit test cases so you have mentioned about the method overloading would you describe that what is Method or overloading yeah basically uh let's say if we have multiple method with same names let's say add uh add data add data is of method which basically add teacher data to database and add a student data to database for example so now uh if I declare this add data method in a interface and expose interface outside the package then using this interface I can decide which one to be called add data of teacher or student based on whatever structure we have assigned to the interface so if I assign let's say if a variable I have created a interface variable of type of any name operations and that operation I assign it student structure inside that and then after assigning student structure I am trying to call the add data then it is going to call the add data of student method in if I do the teacher then it is going to call the teacher one so now I can see this is called as method overloading like but what's the difference between a function and a method yeah so uh function is a straightforward a collection of statement I can say which can be called uh and it is basically create to uh increase the code readability and organizing the code and second thing is like uh reuse of code also can be there if we create a function and method is something is like uh mostly method is created when we wanted to restrict the access restrict the x axis of a function so basically uh when we attach any function to a structure as a receiving parameter uh then in that case uh what happen is like it converts to method for example let's see if there is a function name add user so add user is able to like we can call add user without any structure criteria whereas if I create a method add user that is attached to student now this ad user is only be able to call when a student is there structure we cannot call it directly so I can say that the basic difference is like uh when we attach a structure to a function it become method so yeah what's the uh map in golang uh so map is basically I can see a very useful data structure in go language which is provided to us it is key value pair uh data structure it have key and value key is always going to be unique value can be repetitive and second thing is like uh we can whenever we are reading a map we can pass the key it returns two things one is value and another is the Boolean flag which will tell whether the value of that key is there or not so I can say it is a simply I can say it is a key value pair database data structure and uh it uh the key are going to be always unique and values can be repetitive okay so have you heard about the importance and non-importance in golang yeah Imports and non-inputs what I can say is like uh uh yeah so basically when we say importable and non-importable what I say is like let's say I create a structure and I keep the first letter small it means it is not going to be imported like we cannot import that structure now or this knot goes only with the structure sorry for interrupting so importing means what what you uh know what we know about the importing like basically when we say importing it means we are in package a and we are trying to use something from package B okay so in that case we say importing is going to be take place because in the starting of the our uh any file we have import also so in that Imports we mention all the import libraries so from import libraries we basically use some functionalities or some structure or something as per our requirement so importing Works only when the first letter is caps and that is I can say one clever implementation of the go language where basically uh what the designer did is like a designer in the sense the guys who invented Yeah so basically they said that if the first letter is capital then things can be imported if not then it cannot be imported it it is valid for a structure variable function method everything okay so the first letter should be a uh well then in that case we can Import Auto Service so uh what is go routine in golang uh uh go routine I can say uh is one of the most important feature of go language which is basically provide us the feature of running two function or more than two function concurrently okay yeah so what do you mean by concurrently uh concurrently in the sense same time uh we can see the output actually not same time that depends on number of cores let's say we if we have two cores and we have three uh two process uh two functions running concurrently it means in actuality they may run in parallel parallel in the sense one of them is going to execute on core one and one of them is going to execute On Core 2 and if we draw a Time axis any point of time we can see it is going to cut both of them whereas uh let's say if we have five functions now five process running in parallel concurrently in that case what will happen is like uh since there are only two cores now they are going to switch very fast for a moment a is going to run process a then process B then again process a process G they are going to switch very fast it will look like to us like they are running in parallel but it is kind of Illusion so we can say they are running in concurrent way so what's the difference between concurrently running functions and the parallel running function so parallelism versus concurrent concurrency what I can say is like parallelism uh is a completely Hardware dependent kind of thing concurrency is kind of something which achieve parallelism by switching process very fast uh yeah so go is uh go is something which is built to use uh parallelism very efficiently which is also called as concurrency okay so have you heard about channel uh channels so could you describe channels is a mechanism to communicate between go routines like uh we are dealing we are our last question is like where two processes are running at the same time now what happen is like when they are running in same time then how they are going to communicate so their channels come in a picture basically they provide some mechanism to communicate between the multiple go routines I can see so it's a medium to just communicate between the routines yes okay uh so have you heard about verdiac function uh yeah varetic function is basically a function which can have variable number of input parameters like what does let's say if I have a function add and in ad we have a parameter and a parameter is a as an input and it is basically adding all the things uh and returning or printing the output basically if a is of variated type it means uh while calling this add function I can pass any number of integers it will add all of those and return the output or print the output so there are multiple text Channel as well would you describe what are those yes basically a buffered channel unbuffered channel the there are two uh channel channel types based on the memory size and based on direction also there is a bi-directional unidirectional so there there are two different uh I can say perspective of classification the buffered unoffered is basically like uh when we say a channel is buffered up to level five or six or any number of integer it means it can store that many number of values before getting consumed what I mean to say is that let's say if we have Channel a and we pass a value to Channel A now unless that value is consumed it is not going to accept any other value if it is unbuffered let's see if it is buffered to two levels it means it can cons take two values before start discarding okay and directional by uh is bi-directional unidirectional means we can set that this channel is going to accept the value only from this function and the uh it means it is unidirectional and if any channel is specified like it can receive and send from this function then that channel is bi-directional uh perspective to that given function here the catch point or node point is like it's the same channel which can be bi-directional and unidirectional that depends on in the fun the function or method where it is going to be used okay so what is differ in bowling D for I can say is a mechanism uh which work as a try and catch kind of concept of java basically it follows stack architecture and uh the best part of differ is like whenever uh we put anything any function method or any statement after default then that is going to be executed at the end of the function where it is getting put and compiler makes sure that that execute even though code crash so that is how it helps in our recovery also like sometimes our code panic and we want to recover it recover from it so there also differ is going to be helpful because compiler makes sure if recovery is mentioned in the default then it should run at the end of the function oh so if you define multiple uh differs in a like in main function so how that that will be executed it follows the stack architecture so last in first out so the default which is at the end is going to be executed first and then opposite order is going to be followed fine so how we can handle the errors in bowling errors like basically there are multiple types of Errors we have Panic error we have fatal error so fatal error is basically a kind of error which uh which we put or which we which we Face uh like as a developer I create a fatal error only when we I know that without some requirement our code if runs then also going to produce nothing let's say I run my code for the first time and I am trying to connect with the database and uh there is error while connecting the in the database so there is there is no need of the code to run further because if database is not connected then all the operations are going to already fail so in that case I'll choose the fatal error whereas Panic error is also kind of error which we basically choose light like let's say there is a API call and for that particular API call our code breaks in that case I don't want all the other apis call also to be breaked so in that case I'll choose panic over fatal so that I can recover from that and all the others uh API calls are intact so what is anonymous function in Roland Anonymous function what I can say is like a kind of function uh which don't have any name that is why it is also called as Anonymous function and it is used right away when it is declared like we have the diff structure and we have the statement for the anonymous function we run that right away when we are declaring it why we run it right away because later on we cannot call it since it don't have any name okay so why we use actually a Anonymous function uh what's the use purpose of creates creation of the anonymous function yeah basically what happened is like a Anonymous function also going to have some statement now let's say if that is statement I want to run in a good routine so we cannot put go routine for a statement a go routine uh is going to be used for a function so what we do is like we uh couple those statement in enormous function and just run the anonymous function as a go routine now our that statement is running as a parallel process or conical process okay so uh there are different functions like init function we use and we have main function where our whole program runs so what's the difference between both of them what I can say is uh main function is the entry point for our uh main execution what I can say but uh init function is a kind of something which is basically used to initialize some uh prerequisites prerequisite is in the sense let's say uh in main function I am trying to connect with the database and in order to connect with database I need some URLs or port number or something so uh to get those some uh URLs and port number for for connecting to database some function already need to provide this value to our main function what we can do is like we can read that in main function also but we can read that in init function also so init function is something which runs before mean function for sure and we basically uh put only those instruction in init function which are required to run prior or as a prerequisite uh if we want to put business logic in init function that also can be there but then it basically for violates the systematic order of Kodi so a unit function is kind of something which run before main function and whatever we are doing in it in init function that can also be done in the main also but only thing is uh then it uh the structure of the coding and things other things like formatting correctly is going to be violated so that is why we have init function and that runs before main function okay so let's say uh we have created our project in golang okay then how we can run the project okay so there are multiple ways of running the project another is like uh sorry the first way is like uh we can run go run and then main.go main.go is the main file name the file name can be different also uh but the package would be main only so we can use this command go run main.go and another thing is like we can run go build so go build will find out the uh the main package in that particular directory where you are trying to run Google and generate the executable file that executable file is something going to depend on the operating system where you run let's see if it is Mac then it is going to generate a DMG file if it is Windows it is going to generate the exe file for Ubuntu uh it it is going to generate the depth file and last one is the go install keyword which also do the same as the go build only thing is like uh whatever executable file is generated it just move that executable file from that particular directory to the workspace sorry path variable so it just migrate that to path variable so that you can access it from anywhere okay so have you told about me in that like in Mac you will create a DMZ file Once We Run The Go build and for the windows we have uh like different executables so that can be run in only that DMC file will run only in the Mac or it can be run in different uh operating system as well no it can only be run in the Mac only what we can do is like we can generate executable file for other environment also while let's say we are uh doing go bid at that time we can pass environment also operating system even though we are in Mac we can generate executable file for Windows also and then that can run in Windows but uh if DMG is generated then that will run in the Mac only oh look so I think I have done my interview uh so it's good talking with you Michelle thanks okay so let's hope uh it will it go it gone good so for a positive feeder from me as well as from our uh like manager yeah thanks thanks bye okay thank you thanks bye have a good day bye bye
Info
Channel: Coding Concepts
Views: 6,140
Rating: undefined out of 5
Keywords: interview, golang, mock, codingconcepts, coding like, subscribe, coding
Id: 01ya6SkN59Y
Channel Id: undefined
Length: 31min 19sec (1879 seconds)
Published: Sat Apr 29 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.