Business logic turns a business request into behavior the application can execute. In a translation service, it accepts a word and language, then returns the translated word. Keeping this work in a service separates it from handlers and servers, making the behavior easier to test. section 3.1
Define the logic as a small, observable unit:
- Give the service a clear input boundary: a word and a language. section 3.1
- Return an output that represents the required business result. section 3.1
- Capture expected behavior with given-when-then cases before expanding the implementation. section 3.1
A testable translation service
A minimal Go function such as Translate(word string, language string) string gives the business behavior a boundary. Tests can then check English translation, capitalization, and extra spaces without testing the whole server. section 3.1
Listing 3.2 translator.go
package translation #1
func Translate(word string, language string) string {
return "" #2
}
Use the small translator.go listing as a starting point for isolating business behavior from the application entry point. section 3.1









