Coder Social home page Coder Social logo

geektrust_family's Introduction

This document explains how to run the solution in Go.

Assumption in the problem statement

It is said in the problem statement that the names will be unique. In this case, if we try to add a child in the family whose name already exists, there will be a conflict. To avoid this, I have added a check, which stops the code from adding such a child.

Handling Dependencies

The source code has only 1 dependency which can be found in the go.mod file, i.e. Go v1.12

Running The application

Use the command go run main.go <path to the input file>

Building The application

Use the command go build . to see the executable in the same folder. Then run ./geektrust <path to the input file>

Package & Directory structure of your Go application

The main package is geektrust. The project structure is described below:

bin/
    geektrust                           # command executable
src/
    geektrust                           # main package
        main.go                         # start program file
        input.txt                       # sample input file to run the code
        blankInput.txt                  # a blank text file used as an argument for testing
        go.mod                          # go modules file
        actions                         # package for business logic
            commands.go                 # file to run the individual commands of the input
            commands_test.go            # test file for the commands
            readFile.go                 # file to locate, evaluate the file and extract the contents
            readFile_test.go            # test file for the file access functions
        helpers                         # package for constants and helper controls
            constants.go                # collection of all the constants
            fileHelper_test.go          # test file for file access functions
            fileHelper.go               # functions to help access the input file
        models                          # package with the models used
            family_test.go              # test file for family tree based models
            family.go                   # model with structs and functions for family tree
            person_test.go              # test file for person based models
            person.go                   # model with structs and functions for a person
        Readme.md                       # the file you are currently reading

I have initialised the family tree not on program start but after the following conditions are met:

  1. The input file exists
  2. The input file is not empty
  3. The input file has at least 1 valid command, i.e. ADD_CHILD or GET_RELATIONSHIP

I have done this on purpose to save unnecessary memory storage.

geektrust_family's People

Contributors

prasangmisra avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.