forked from ardanlabs/gotraining
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template1.go
43 lines (32 loc) · 1.49 KB
/
template1.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// All material is licensed under the Apache License Version 2.0, January 2004
// http://www.apache.org/licenses/LICENSE-2.0
// Create two error variables, one called ErrInvalidValue and the other
// called ErrAmountTooLarge. Provide the static message for each variable.
// Then write a function called checkAmount that accepts a float64 type value
// and returns an error value. Check the value for zero and if it is, return
// the ErrInvalidValue. Check the value for greater than $1,000 and if it is,
// return the ErrAmountTooLarge. Write a main function to call the checkAmount
// function and check the return error value. Display a proper message to the screen.
package main
// Add imports.
var (
// Declare an error variable named ErrInvalidValue using the New
// function from the errors package.
// Declare an error variable named ErrAmountTooLarge using the New
// function from the errors package.
)
// Declare a function named checkAmount that accepts a value of
// type float64 and returns an error interface value.
func checkAmount( /* parameter */ ) /* return arg */ {
// Is the parameter equal to zero. If so then return
// the error variable.
// Is the parameter greater than 1000. If so then return
// the other error variable.
// Return nil for the error value.
}
func main() {
// Call the checkAmount function and check the error. Then
// use a switch/case to compare the error with each variable.
// Add a default case. Return if there is an error.
// Display everything is good.
}