Go 1.16 was the development setup for this application.
The easiest way to install go is using the official docs. Install golang by following the steps here
If you are on mac, you can run brew install go
to install the latest version of golang.
If you are on Ubuntu, you can follow the steps here - https://github.com/golang/go/wiki/Ubuntu
golang/mock is used in the repo to generate mocks to test for the interface created for different packages.
golangci-lint to do linting locally and in CI.
To install gomock, and golangci-lint run the following command
make install/dependencies
NOTE: curl
is required to run the make command above
Run the following command to start the application in your local terminal.
make run
Or by using go directly
go build -o ./bin/search ./cmd/search
./bin/search
Note: It should be able to build easily using default go env
variables.
To run the tests, run the following make command
make test
Few tests uses golang/mock to generate mocks for the interfaces. To update the generated mocks, run the following:
make test/generate
Run the following command to run linter locally after installing it
make lint
It requires $GOPATH/bin
to be available inside the $PATH
(official Go installer does this by default).
If you are on linux, setting the following in ~/.zshrc
or ~/.bashrc
or any other shell of your choosing and restarting the terminal should work
export PATH="$PATH:$(go env GOPATH)/bin"
Alternatively, you can follow installations instructions here
_id
values are unique per record for all the users, tickets and, organisations.
If you like to contribute, feel free to read the following to navigate the code
- The entrypoint of the application is
cmd/search
which has the main file. - The main file at
cmd/search
starts the application by callingpkg/cmd/search
which has the application logic defined. This is the first layer of the application. It is responsible to keep the application running. The logic to take user input is also defined in this layer - The layer on top of
pkg/cmd/search
is calledpkg/serializer
. Serializer could be a misleading term to what it does. It has the connection to the data store. It takes the input from thepkg/cmd/search
and uses that to fetch the data from the store. It also handles the logic to print the data on the screen. - The layer on top of
pkg/serializer
ispkg/store
, which is initialized by the app and sent to serializer for future use.pkg/store
caches all the data from input files into memory to be fetched by the serializer quickly.