Go interview questions

Go quiz questions

  • 1.

    What are the advantages of GO?

    Answer:

    • GO compiles very quickly
    • Go supports concurrency at the language level
    • Functions are first class objects in GO
    • GO has garbage collection
    • Strings and Maps are built into the language
    View
  • 2.

    Explain what is string types?

    Answer:

    A string type represents the set of string values, and string values are sequence of bytes.  Strings once created is not possible to change.

    View
  • 3.

    Explain how you can do testing in GO?

    Answer:

    It has a lightweight testing framework consists of the go test command and the testing package.

    To write a test you have to create a file with a name ending in _testing. Go which contains functions named TestXXX with signature func (t *testing.T).  The test framework runs each such function.

    View
  • 4.

    Explain what is GOPATH environment variable?

    Answer:

    The GOPATH environment variable determines the location of the workspace. It is the only environment variable that you have to set when developing Go code.

    View
  • 5.

    Explain how to use custom packages in GO language?

    Answer:

    If you are making your library a separate go get –table project and if your library is for internal use then you can code like this

    • Under the directory of your project place the directory with library files
    • Refer to the library using its path relative to the root of your workspace consisting the project

    For example,

    src/

    myproject/

    mylib/

    mylib.go

    . . .

    main.go

    Now, in main.go you could import myprojec/mylib.

    View
  • 6.

    Explain workspace in GO?

    Answer:

    Inside a workspace GO code must be kept.  A workspace is a directory hierarchy with three directories at its root.

    • src contains GO source files organized into packages
    • pkg contains package objects and
    • bin contains executable commands
    View
  • 7.

    Explain packages in Go program?

    Answer:

    Every GO program is made up of packages.  The program starts running in package main.  This program is using the packages with import paths “fmt” and “math/rand”.

    View
  • 8.

    Explain what is string literals?

    Answer:

    A string literals represents a string constant obtained from concatenating a sequence of characters.

    There are two forms,

    • Raw string literals: The value of raw string literals are character sequence between back quotes ‘‘.  The value of a string literal is the string composed of the uninterrupted character between quotes.
    • Interpreted string literals: It is represented between double quotes ““. The text between the double quotes which may not contain newlines, forms the value of the literal.
    View
  • 9.

    What is syntax like in GO?

    Answer:

    Syntax in GO is specified using Extended Backus-Naur Form (EBNF)

    • Production = production_name “=” [ Expression ]
    • Expression = Alternative { “l” Alternative }
    • Alternative = Term { Term }
    • Term = Production_name l token [ “…”token] l Group l Option l Repetition
    • Group = “ ( “ Expression”)”
    • Option = “ [ “ Expression “ ]”
    • Repetition = “ {“ Expression “}”
    View
  • 10.

    Explain what is GO?

    Answer:

    GO is an open source programming language which makes it easy to build simple, reliable and efficient software. Programs are constructed from packages, whose properties allow efficient management of dependencies.

    View

© 2017 QuizBucket.org