{"record":{"id":"da7283458615f736","repo":"inancgumus/learngo","slug":"wrong-operation-op-da7283","errorCode":null,"errorMessage":"Wrong operation: '<op>'","messagePattern":"Wrong operation: '<op>'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"x-tba/foundations/calc/09-packages/calc/calc.go","lineNumber":41,"sourceCode":"// Do ...\nfunc Do(a, b float64, op string) (res float64, err error) {\n\tswitch op {\n\tcase \"+\", \"plus\":\n\t\top, res = \"+\", a+b\n\tcase \"-\", \"minus\":\n\t\top, res = \"-\", a-b\n\tcase \"*\", \"times\":\n\t\top, res = \"*\", a*b\n\tcase \"/\", \"div\":\n\t\top, res = \"/\", a/b\n\tcase \"%\", \"mod\":\n\t\tres = float64(int(a) % int(b))\n\tdefault:\n\t\treturn 0, errors.New(\"Wrong operation: '\" + op + \"'\")\n\t}\n\treturn\n}","sourceCodeStart":23,"sourceCodeEnd":45,"githubUrl":"https://github.com/inancgumus/learngo/blob/3c475a78e54336c6255e925ff66b8ef4da6a2ae7/x-tba/foundations/calc/09-packages/calc/calc.go#L23-L45","documentation":"Do() returns this error when the op argument does not match any of the supported operators: +/plus, -/minus, */times, //div, %/mod. The switch's default branch rejects unknown or misspelled operation strings coming from the command line.","triggerScenarios":"Thrown at x-tba/foundations/calc/09-packages/calc/calc.go:41 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Print the supported operator list (+, -, *, /, %) and their word aliases, then exit with a non-zero status.","Validate the op argument before calling calc.Do (e.g., in main when parsing flags).","Normalize user input (lowercase, trim) so aliases like \"PLUS\" map to the accepted forms."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3c475a78e54336c6255e925ff66b8ef4da6a2ae7","analyzedAt":"2026-09-02T10:14:38.492Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}