File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package env
3
3
import "errors"
4
4
5
5
var (
6
+ ErrNilLoader = errors .New ("loader cannot be nil" )
6
7
ErrEnvironmentVariableNotFound = "environment variable not found: %v"
7
8
ErrFailedToLoadEnvironmentVariables = errors .New ("failed to load environment variables" )
8
9
ErrInvalidDuration = "invalid key '%v' duration value: %v"
Original file line number Diff line number Diff line change @@ -12,11 +12,16 @@ type Port struct {
12
12
}
13
13
14
14
// LoadPort load port from environment variables
15
- func LoadPort (host string , key string ) (
15
+ func LoadPort (loader goloaderenv. Loader , host string , key string ) (
16
16
* Port , error ,
17
17
) {
18
+ // Check if loader is nil
19
+ if loader == nil {
20
+ return nil , goloaderenv .ErrNilLoader
21
+ }
22
+
18
23
// Get environment variable
19
- port , err := goloaderenv .LoadVariable (key )
24
+ port , err := loader .LoadVariable (key )
20
25
if err != nil {
21
26
return nil , err
22
27
}
You can’t perform that action at this time.
0 commit comments