8. Packages
Activity 8.01: Creating a Function to Calculate Payroll and Performance Review
Solution:
All directories and files should be created inside of $GOPATH
:
- Create a directory called
Activity8.01
. - Create a directory called
pay
andpayroll
insideActivity8.01
. - Create a file called
main.go
insideChapter08/Activity8.01/pay
. - Create the following files:
developer.go
,employee.go
, andmanager.go
insidepayroll
. - The directory structure and files should look similar to the following screenshot:
- Inside
Chapter08/Activity8.01/payroll/developer.go
, declare the package aspayroll
:package payroll import ( Â Â "errors" Â Â "fmt" )
- The
Developer
type, and the following methods,Pay()
andReviewRating()
, will all be exportable, so the first letter needs to be capitalized. This means that they are visible to other packages outside ofpayroll
. - From https://packt.live/2YNnfS6...