Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
OOP and REST API in Go
00:00
5 left

OOP and REST API in Go

HardPython

Problem

Describe how you apply object-oriented design principles in Go and how you implement a REST API.

For the hands-on portion, implement the equivalent resource handler below. Support GET, POST, PUT, and DELETE for /items and /items/{id}, while separating routing, validation, and resource operations. Return a response object containing an HTTP-style status code and JSON-compatible body.

Contract

process_request(items, method, path, body) receives a list of item objects and returns {"status": integer, "body": value}. Each item has an integer id and string name.

Constraints

  • 0 <= len(items) <= 10^4
  • Each item contains a unique positive integer id and a string name
  • method is one of GET, POST, PUT, or DELETE
  • path uses /items or /items/{id}
  • POST and PUT bodies must contain a non-empty string name

Function Signature

def process_request(items, method, path, body):
Interviewer

Your question is OOP and REST API in Go. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.