Hi everyone, in this hands on blog i would like to demonstrate simple unit testing in Golang which will help you get started. Let’s take simple go file (main.go) where there is an interface and a concrete implementation that we will test in this blog lab.
Let’s examine the contents of the file.
LoanInfostruct which is a simple model with one field
interestInPercent. As the name suggests, its a model representing information about a Loan.
NewLoanInfoLoanInfo constructor function with basic validation.
Calculatorinterface which has one abstract method
SimpleInterest, takes principal amount (USD)…