calc

package
v1.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddRequest

type AddRequest struct {
	// A is the first number to add.
	A int
	// B is the other number to add.
	B int
}

AddRequest wrangles the two integers you plan to add together.

type AddResponse

type AddResponse struct {
	// Result is the sum you're returning.
	Result int
}

AddResponse contains the result from adding two numbers.

type CalculatorService

type CalculatorService interface {
	// Add accepts two integers and returns a result w/ their sum.
	Add(context.Context, *AddRequest) (*AddResponse, error)
	// Sub accepts two integers and returns a result w/ their difference.
	Sub(context.Context, *SubRequest) (*SubResponse, error)
}

CalculatorService provides the ability to add and subtract at WEB SCALE!

type CalculatorServiceHandler

type CalculatorServiceHandler struct{}

CalculatorServiceHandler implements all of the "real" functionality for the CalculatorService. The errors that Add/Sub return are completely contrived and don't make sense for real business logic. They are only included to show how you can return specific types of 4XX errors in a readable/maintainable fashion.

func (CalculatorServiceHandler) Add

Add accepts two integers and returns a result w/ their sum.

func (CalculatorServiceHandler) Sub

Sub accepts two integers and returns a result w/ their difference.

type SubRequest

type SubRequest struct {
	// A is the "minuend" in the subtraction operation.
	A int
	// B is the "subtrahend" in the subtraction operation.
	B int
}

SubRequest wrangles the two integers you plan to subtract.

type SubResponse

type SubResponse struct {
	// Result is the difference you're returning.
	Result int
}

SubResponse contains the result from subtracting two numbers.

Directories

Path Synopsis
Code generated by Frodo - DO NOT EDIT.
Code generated by Frodo - DO NOT EDIT.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL