Exercises & activities from the go workshop provided by Packt: https://courses.packtpub.com/courses/go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
506 B

  1. package main
  2. import "fmt"
  3. func main() {
  4. devSalary := salary(50, 2080, developerSalary)
  5. bossSalary := salary(150000, 25000, managerSalary)
  6. fmt.Printf("Boss salary: %d\n", bossSalary)
  7. fmt.Printf("Developer salary: %d\n", devSalary)
  8. }
  9. func salary(x, y int, f func(int, int) int) int {
  10. pay := f(x, y)
  11. return pay
  12. }
  13. func developerSalary(hourlyRate, hoursWorked int) int {
  14. return hourlyRate * hoursWorked
  15. }
  16. func managerSalary(baseSalary, bonus int) int {
  17. return baseSalary + bonus
  18. }