Code candidates will extend as part of their technical interview process. The order-up service handles all order-specific calls including creating orders, checking the status on orders, etc. This service is part of a larger microservice backend for a online marketplace.
You also will need to install Go. Then clone this
this repository and run go mod tidy within this repository to download all
necessary dependencies locally.
The top-level only contains a single main.go file which holds the main
function. If you ran go build ./. that would produce a order-up binary that
would start by executing the main function in main.go.
The api package handles incoming HTTP requests with a REST paradigm and calls
various functions based on the path. This package uses the storage package to
perform the necessary functionality for each API call. The tests use a mocked
storage instance.
The storage package contains an in-memory implementation for persisting and retrieving orders. You are expected to extend this implementation to satisfy the tests and documented functionality.
The mocks package just contains a helper function for mocking an external
service by accepting an http.Handler and returning a *http.Client as well as
generated code for mocking a *storage.Instance. This simply makes the tests
easier in the api package.
go mod tidydownloads all dependencies and updatego.modfile with any new dependenciesgo test -v -race ./...tests all files and subdirectories. You can instead dogo test -v ./storage/...to only test the storage package. Any public function with the formatTestX(*testing.T)will automatically be called bygo test. Typically these functions are placed inX_test.gofiles. You can pass a regex to-runlike-run ^TestInsertOrder$in order to just run tests matching the regex.go fmt ./...reformats the go files according to the gofmt specgo vet ./...prints out most-likely errors or mistakes in Go codego get $packageadds a new dependency to the current project