Q.What Is Go?

Ans: Go is a general-purpose language designed with systems programming in mind.It was initially developed at Google in year 2007 by Robert Griesemer, Rob Pike, and Ken Thompson. It is strongly and statically typed, provides inbuilt support for garbage collection and supports concurrent programming. Programs are constructed using packages, for efficient management of dependencies. Go programming implementations use a traditional compile and link model to generate executable binaries.

Q.What Are The Benefits Of Using Go Programming?


  • Compilation time is fast.
  • Conciseness, Simplicity, and Safety.
  • Support for Interfaces and Type embdding.
  • Production of statically linked native binaries without external dependencies.

Q.Does Go Support Type Inheritance?

Ans: No support for type inheritance.

Q.Does Go Support Operator Overloading?

Ans: No support for operator overloading.

Q.Does Go Support Method Overloading?

Ans: No support for method overloading.

Q.Does Go Support Pointer Arithmetics?

Ans: No support for pointer arithmetic.

Q.Does Go Support Generic Programming?

Ans: No support for generic programming.

Q.Is Go A Case Sensitive Language?

Ans: Yes! Go is a case sensitive programming language.

Q.What Is Static Type Declaration Of A Variable In Go?


Q.What Is Dynamic Type Declaration Of A Variable In Go?

Ans: A dynamic type variable declaration requires compiler to interpret the type of variable based on value passed to it. Compiler don’t need a variable to have type statically as a necessary requirement.

Q.Can You Declared Multiple Types Of Variables In Single Declaration In Go?

Ans: Yes Variables of different types can be declared in one go using type inference.

var a, b, c = 3, 4, “foo”

Q.How To Print Type Of A Variable In Go?

Ans: Following code prints the type of a variable −

fmt.Printf(“a is of type %Tn”, a)

Q.What Is A Pointer?

Ans: It’s a pointer variable which can hold the address of a variable.

For example −

var x = 5
var p *int
p = &x
fmt.Printf(“x = %d”, *p)
Here x can be accessed by *p.

Q.What Is The Purpose Of Break Statement?

Ans: Break terminates the for loop or switch statement and transfers execution to the statement immediately following the for loop or switch.

Q.What Is The Purpose Of Continue Statement?

Ans: Continue causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.

Q.What Is The Purpose Of Goto Statement?

Ans: goto transfers control to the labeled statement.

Q.Explain The Syntax For ‘for’ Loop?

Ans: The syntax of a for loop in Go programming language is −

for [condition |  ( init; condition; increment ) | Range]

Here is the flow of control in a for loop −

  • if condition is available, then for loop executes as long as condition is true.
  • if for clause that is ( init; condition; increment ) is present then
  • if range is available, then for loop executes for each item in the range.

Q.Explain The Syntax To Create A Function In Go?

Ans: The general form of a function definition in Go programming language is as follows −

func function_name( [parameter list] ) [return_types]
body of the function

A function definition in Go programming language consists of a function header and a function body. Here are all the parts of a function −

  • func func starts the declaration of a function.
  • Function Name − This is the actual name of the function. The function name and the parameter list together constitute the function signature.
  • Return Type − A function may return a list of values. The return_types is the list of data types of the values the function returns. Some functions perform the desired operations without returning a value. In this case, the return_type is the not required.
  • Function Body − The function body contains a collection of statements that define what the function does.

Q.Can You Return Multiple Values From A Function?

Ans: A Go function can return multiple values. For example −

package main
import “fmt”
func swap(x, y string) (string, string) {
return y, x
func main() {
a, b := swap(“Mahesh”, “Kumar”)
fmt.Println(a, b)

Q.In How Many Ways You Can Pass Parameters To A Method?


While calling a function, there are two ways that arguments can be passed to a function:


Q.What Is The Default Way Of Passing Parameters To A Function?

Ans: By default, Go uses call by value to pass arguments. In general, this means that code within a function cannot alter the arguments used to call the function while calling max() function used the same method.

Q.What Do You Mean By Function As Value In Go?

Ans: Go programming language provides flexibility to create functions on the fly and use them as values. We can set a variable with a function definition and use it as parameter to a function.

Q.What Are The Function Closures?

Ans: Functions closure are anonymous functions and can be used in dynamic programming.

Q.What Are Methods In Go?

Ans: Go programming language supports special types of functions called methods. In method declaration syntax, a “receiver” is present to represent the container of the function. This receiver can be used to call function using “.” operator.

Q.What Is Default Value Of A Local Variable In Go?

Ans: A local variable has default value as it corresponding 0 value.

Q.What Is Default Value Of A Global Variable In Go?

Ans: A global variable has default value as it corresponding 0 value.

Q.What Is Default Value Of A Pointer Variable In Go?

Ans: Pointer is initialized to nil.

Q.Explain The Purpose Of The Function Printf()?

Ans: Prints the formatted output.

Q.What Is Lvalue And Rvalue?

Ans: The expression appearing on right side of the assignment operator is called as rvalue. Rvalue is assigned to lvalue, which appears on left side of the assignment operator. The lvalue should designate to a variable not a constant.

Q.What Is The Difference Between Actual And Formal Parameters?

Ans: The parameters sent to the function at calling end are called as actual parameters while at the receiving of the function definition called as formal parameters.

Q.What Is The Difference Between Variable Declaration And Variable Definition?

Ans: Declaration associates type to the variable whereas definition gives the value to the variable.

Q.Explain Modular Programming?

Ans: Dividing the program in to sub programs (modules/function) to achieve the given task is modular approach. More generic functions definition gives the ability to re-use the functions, such as built-in library functions.

Q.What Is A Token?

Ans: A Go program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol.

Q.Which Key Word Is Used To Perform Unconditional Branching?

Ans: goto

Q.What Is An Array?

Ans: Array is collection of similar data items under a common name.

Q.What Is A Nil Pointers In Go?

Ans: Go compiler assign a Nil value to a pointer variable in case you do not have exact address to be assigned. This is done at the time of variable declaration. A pointer that is assigned nil is called a nil pointer. The nil pointer is a constant with a value of zero defined in several standard libraries.

Q.What Is A Pointer On Pointer?

Ans: It’s a pointer variable which can hold the address of another pointer variable. It de-refers twice to point to the data held by the designated pointer variable.

var a int
var ptr *int
var pptr **int
a = 3000
ptr = &a
pptr = &ptr
fmt.Printf(“Value available at **pptr = %dn”, **pptr)
Therefore ‘a’ can be accessed by **pptr.

Q.What Is Structure In Go?

Ans: Structure is another user defined data type available in Go programming, which allows you to combine data items of different kinds.

Q.How To Define A Structure In Go?

Ans: To define a structure, you must use type and struct statements. The struct statement defines a new data type, with more than one member for your program. type statement binds a name with the type which is struct in our case.

The format of the struct statement is this −

type struct_variable_type struct {
member definition;
member definition;

member definition;

Q.What Is Slice In Go?

Ans: Go Slice is an abstraction over Go Array. As Go Array allows you to define type of variables that can hold several data items of the same kind but it do not provide any inbuilt method to increase size of it dynamically or get a sub-array of its own. Slices covers this limitation. It provides many utility functions required on Array and is widely used in Go programming.

Q.How To Define A Slice In Go?

Ans: To define a slice, you can declare it as an array without specifying size or use make function to create the one.

var numbers []int /* a slice of unspecified size */
/* numbers == []int{0,0,0,0,0}*/
numbers = make([]int,5,5) /* a slice of length 5 and capacity 5*/

Q.How To Get The Count Of Elements Present In A Slice?

Ans: len() function returns the elements presents in the slice.

Q.What Is The Difference Between Len() And Cap() Functions Of Slice In Go?

Ans: len() function returns the elements presents in the slice where cap() function returns the capacity of slice as how many elements it can be accomodate.

Q.How To Get A Sub-slice Of A Slice?

Ans: Slice allows lower-bound and upper bound to be specified to get the subslice of it using[lower-bound:upper-bound].

Q.What Is Range In Go?

Ans: The range keyword is used in for loop to iterate over items of an array, slice, channel or map. With array and slices, it returns the index of the item as integer. With maps, it returns the key of the next key-value pair.

Q.What Are Maps In Go?

Ans: Go provides another important data type map which maps unique keys to values. A key is an object that you use to retrieve a value at a later date. Given a key and a value, you can strore the value in a Map object. After value is stored, you can retrieve it by using its key.

Q.How To Create A Map In Go?


You must use make function to create a map.

/* declare a variable, by default map will be nil*/
var map_variable map[key_data_type]value_data_type
/* define the map as nil map can not be assigned any value*/
map_variable = make(map[key_data_type]value_data_type)

Q.How To Delete An Entry From A Map In Go?

Ans: delete() function is used to delete an entry from the map. It requires map and corresponding key which is to be deleted.

Q.What Is Type Casting In Go?

Ans: Type casting is a way to convert a variable from one data type to another data type. For example, if you want to store a long value into a simple integer then you can type cast long to int. You can convert values from one type to another using the cast operator as following:


Q.What Are Interfaces In Go?

Ans: Go programming provides another data type called interfaces which represents a set of method signatures. struct data type implements these interfaces to have method definitions for the method signature of the interfaces.

Contact for more on Go Language Online Training

Go Language interview Questions Overall rating: ★★★★☆ 4.4 based on 435 reviews
5 1

Write A Review 

Review Title
Review Content

go language interview questions Tags

go language interview questions and answers, go language online training, go language interview questions, go language training online, go language training, go language training institute, latest go language interview questions, best go language interview questions 2019, top 100 go language interview questions,sample go language interview questions,go language interview questions technical, best go language interview tips, best go language interview basics, go language Interview techniques, go language Interview Tips.

For  online training videos