5. Functions
Activity 5.01: Calculating the Working Hours of Employees
Solution:
All directories and files should be created inside your $GOPATH
:
- Create a directory called
Activity5.01
. - Create a file called
main.go
insideActivity5.01
. - Inside
Activity5.01/main.go
, declare themain
package and its imports:package main import "fmt"
- Create a
Developer
type. Notice theWorkWeek
is an array of7
. This is because the week consists of 7 days and we use an array to ensure the fixed size:type Developer struct {   Individual Employee   HourlyRate int   WorkWeek [7]int }
- Create an
Employee
type:type Employee struct {   Id int   FirstName string   LastName string }
- Create a
Weekday
of typeint
:type Weekday int
- Create a constant of type
Weekday
. This is an enumeration of the weekdays:const (   Sunday Weekday = iota //starts at zero   Monday   Tuesday...